bouffalolab / bouffalo_sdk

BouffaloSDK is the IOT and MCU software development kit provided by the Bouffalo Lab Team, supports all the series of Bouffalo chips. Also it is the combination of bl_mcu_sdk and bl_iot_sdk
Apache License 2.0
371 stars 127 forks source link

[Info] Enable the LP core of BL808 and receive "Hello world" msg from LP core #105

Closed cjacker closed 1 year ago

cjacker commented 1 year ago

Update: too quick response from upstream developer, my work already upstreamed.

Here is a demo 'tripplecore' for it: https://github.com/cjacker/opensource-toolchain-bouffalo-lab/tree/main/triplecore_bl808

Install XuanTie RISC-V toolchain

wget https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1663142243961/Xuantie-900-gcc-elf-newlib-x86_64-V2.6.1-20220906.tar.gz
sudo mkdir -p /opt/xuantie-riscv64-embed-toolchain
sudo tar xf Xuantie-900-gcc-elf-newlib-x86_64-V2.6.1-20220906.tar.gz -C /opt/xuantie-riscv64-embed-toolchain --strip-components=1

And add /opt/xuantie-riscv64-embed-toolchain/bin to PATH env according to your shell.

Apply patch to bl_mcu_sdk

Update: it's already upstreamed.

Build this triplecore demo

Enter 'bl_mcu_sdk/examples/bl808_triplecore' dir and type make directly.

After build successfully, these firmware files will be generated:

Program to bl808

Since BLDevCube GUI tool not support Group2 in BL808 MCU page, you can not program these firmwares in one time.

I suggest to program it one by one by BLFlashCommand, you may need to activate UART programming mode every time.

Here use Sipeed M1S Dock as example.

M1S Dock will enter UART programming mode.

Then:

cd helloworld_m0
make flash

After programmed, you need re-power M1S Dock and continue programming firmwares for d0 and lp core as above steps.

Wire up USB2TTL adapters

After all three firmware programmed, Wire 3 USB2TTL adapter as:

For M1S Dock, since it already have 2 UARTs (emulated by BL702) connect to D0 and M0, you only need wire another USB2TTL adapter to GPIO 18 and GPIO 19 for LP core.

For my env, the 3 serial devices are :

Check it according to your env.

Receive hello world from 3 cores

Use any serial terminal such as tio / minicom / picocom / cutecom, etc. Set baudrate to 2000000, 8N1, and open 3 serial devices.

You will receive "hello world" from 3 cores.

To restore factory firmwares for Sipeed M1S Dock

Use these scripts and firmware to restore the factory firmwares for Sipeed M1S Dock:

https://github.com/cjacker/opensource-toolchain-bouffalo-lab/tree/main/m1s_dock_factory_firmware

More

sakumisu commented 1 year ago

Hi, @cjacker thank you for your effort, you do the same code as mine, could you please pr this patch into master?

cjacker commented 1 year ago

OK, I will send a PR.

cjacker commented 1 year ago

By the way, could you update BLDevCube for various platforms to add 'Group2' support to MCU page? After that, these firmwares can be programmed in one time.

Fishwaldo commented 1 year ago

There still is a issue with overlapping RAM regions in the linker scripts for M0/LP

If M0 uses more than 16K ram, it will walk over the memory for LP

sakumisue commented 1 year ago

There still is a issue with overlapping RAM regions in the linker scripts for M0/LP

If M0 uses more than 16K ram, it will walk over the memory for LP

This depends on user code, it is variable.