openbouffalo / buildroot_bouffalo

Linux Image for the BL808 CPU by Bouffalo Lab
124 stars 33 forks source link

Please consider to combined all firmwares together and get rid of depending on bldevcube. #47

Open cjacker opened 1 year ago

cjacker commented 1 year ago

Combine m0/d0 lowload and bl808-firmware.bin together:

  1. create a empty image with size 0x800000, fill it with "0xFF". 0x800000 is the start addr of "bl808-firmware.bin", it will be appended later.

    dd if=/dev/zero bs=8388608 count=1| tr "\000" "\377" >openbouffalo-bl808.bin
  2. copy "m0_lowload_bl808_m0.bin" to the start of whole firmware.

    dd conv=notrunc if=m0_lowload_bl808_m0.bin of=openbouffalo-bl808.bin
  3. copy d0 lowload to 0x100000 of whole firmware

    dd conv=notrunc if=d0_lowload_bl808_d0.bin of=openbouffalo-bl808.bin seek=1048576 bs=1
  4. append bl808-firmware.bin to the end

    cat bl808-firmware.bin >> openbouffalo-bl808.bin

The final 'openbouffalo-bl808.bin' can be programed from CLI as:

bflb-iot-tool --chipname bl808 --interface uart --port /dev/ttyUSB1 --baudrate 2000000 --firmware openbouffalo-bl808.bin --addr 0x0 --single

it can also able to be programmed by BLDevCube from IOT page.

leow149 commented 1 year ago

Please try with my changed post-build.sh and see if it works for you, then i will create a pull request.

Fishwaldo commented 1 year ago

Two things here:

So I'm reluctant to do this unless the changes don't impact the existing workflow.

(Also, we have a yocto image now available that is a bit more flexible with regards to packages etc. I want to keep the buildroot and yocto rootfs images compatible with the low load/bl808-firmware so it's easy to swap between images).

leow149 commented 1 year ago

My changes should just create a additional image in the binary folder and leave the rest untouched

cjacker commented 1 year ago

Two things here:

* bflb_iot_tool (and BLDevCube) are being depreciated. We should use the BLFlashCube/BLFlashCommand instead but as I understand it, there is no separate download for those tools available for users that do not wish to install bl_mu_sdk.

Off topic:

It seems other tools couldn't be be replaced by BLFlashCube/Command, and seems upstream didn't intend to do that, they just create two new tools for bl_mcu_sdk and it lacks a lot of features other tools have. but it did one thing right, flash the firmware to an exact address, just like iot-tool single image did.

BL upstream really made things complex. no matter partition tables, old or new firmwares can be preprocessed and finally use a unified tool to flash to a specific address. but upstream choose process them with different tools when flashing and seems all these different tools have the same core code base.

* there are users that have their own firmware to run on M0 (such as uboot). In addition, we hope for a update soon where m0 low load will not be required for Linux to operate.

Sound reasonable.

Then just leave it here as reference in case anyone need this. actually other firmwares can be processed this way and generate a whole or several seperate firmwares and can be programmed by DevCube, BLFlashCommand/Cube or bf-iot-tool.

bf-mcu-tool is another story, it will add a 0x2000 offset to addr specified by cli arg.

dotsam commented 1 year ago

Thanks for this, I was having issues with the MCU tab of BLDevCube on macOS (group0 img len error, get 61664 except 1075840 for anyone searching/wondering. I suspect some sort of file read/write race condition, as the generated file does seem to actually be 1075840 bytes), and this was a workaround.

One note, the default LANG on macOS will cause problems with the first command, so to be safe, that should be redefined inline with tr

dd if=/dev/zero bs=8388608 count=1 | LC_ALL=C tr "\000" "\377" > openbouffalo-bl808.bin