Giter Site home page Giter Site logo

bouffalolab / bl808_linux Goto Github PK

View Code? Open in Web Editor NEW
126.0 25.0 39.0 253.32 MB

License: Apache License 2.0

CMake 0.01% Makefile 0.25% C 98.05% C++ 0.03% Assembly 1.06% Shell 0.29% Roff 0.02% Perl 0.13% Awk 0.01% Python 0.13% sed 0.01% Yacc 0.01% Lex 0.01% UnrealScript 0.01% SmPL 0.02% XS 0.01% Raku 0.01% Clojure 0.01% M4 0.01%

bl808_linux's Introduction

bl808_linux

bl808 Linux

.
├── bl808_dts         # kernel dts file
├── bl_mcu_sdk_bl808  # bl_mcu_sdk for build low load bin
├── build.sh          # build script
├── linux-5.10.4-808  # linux kernel code
├── opensbi-0.6-808   # opensbi code
├── out               # bin file output dir
├── toolchain         # build need toolchain
└── README.md         # readme file

Environment Setup

Ubuntu20.04 needs to use apt to install the package:

sudo apt install flex bison libncurses-dev device-tree-compiler lz4

Download toolchains

mkdir -p toolchain/cmake toolchain/elf_newlib_toolchain toolchain/linux_toolchain
curl https://cmake.org/files/v3.19/cmake-3.19.3-Linux-x86_64.tar.gz | tar xz -C toolchain/cmake/ --strip-components=1
curl https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1663142243961/Xuantie-900-gcc-elf-newlib-x86_64-V2.6.1-20220906.tar.gz | tar xz -C toolchain/elf_newlib_toolchain/ --strip-components=1
curl https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1663142514282/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1-20220906.tar.gz | tar xz -C toolchain/linux_toolchain/ --strip-components=1

Compile

Step by step

./build.sh --help
./build.sh opensbi
./build.sh kernel_config
./build.sh kernel
./build.sh dtb
./build.sh low_load
./build.sh whole_bin

Or

./build.sh all

Then find the firmwares under out

├── fw_jump.bin
├── hw.dtb.5M
├── Image.lz4
├── squashfs_test.img 
├── low_load_bl808_d0.bin 
├── low_load_bl808_m0.bin 
├── merge_7_5Mbin.py
└── whole_img_linux.bin

Download Firmware

  • Get the latest version of DevCube from http://dev.bouffalolab.com/download
  • Connect BL808 board with PC by USB cable
  • Set BL808 board to programming mode
    • Press BOOT button
    • Press RESET button
    • Release RESET button
    • Release BOOT button
  • Run DevCube, select [BL808], and switch to [MCU] page
  • Select the uart port and set baudrate with 2000000
  • M0 Group[Group0] Image Addr [0x58000000] [PATH to low_load_bl808_m0.bin]
  • D0 Group[Group1] Image Addr [0x58000000] [PATH to low_load_bl808_d0.bin]
  • Click 'Create & Download' and wait until it's done
  • Switch to [IOT] page
  • Enable 'Single Download', set Address with 0xD2000, choose [PATH to whole_image_linux.bin]
  • Click 'Create & Download' again and wait until it's done

Boot BL808 board

Press and release RESET button, E907 will output log by IO14(TX)/IO15(RX) and C906 by IO5(RX)/IO8(TX)

Changelog

2023-08-21

bl808_linux's People

Contributors

chinawrj avatar gamelaster avatar ivq avatar taorye avatar yafeijin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bl808_linux's Issues

Missing config

The current build scripts doesn't use any config. There are two ones: config_release_0.3.0 and c906.config , Which one is correct one? Also, can we add into scripts to use one of them by default, so it doesn't need manual renaming?

Kernel compilation error

Hello,
after run all curls ...
i run switch_to_m1sdock.sh and
`
./build opensbi OK

./build kernel_config (nothing chane) OK

./build kernel
...
YACC scripts/dtc/dtc-parser.tab.[ch]
Makefile:67: /home/mitek/bl808_linux/linux-5.10.4-808/tools/build/Makefile.include: No such file or directory
make[2]: *** No rule to make target '/home/mitek/bl808_linux/linux-5.10.4-808/tools/build/Makefile.include'. Stop.
make[1]: *** [Makefile:71: bpf/resolve_btfids] Error 2
make: *** [Makefile:1931: tools/bpf/resolve_btfids] Error 2
`
Can you help me to resolve ?

Thanks in advance

i2c driver

I want to connect a device via i2c. Is there an example?

Thread Support

Hello All,

I was trying to test threading with this SDK, looks like I'm not able to wrap my head over the proper library and setup in the CMakeLists.txt file. Can anyone help me please?

The below is an example of my CMakeLists.txt file, which compiles fine except for the below warnings:


cmake_minimum_required(VERSION 3.15)

include(proj.conf)

find_package(bouffalo_sdk REQUIRED HINTS $ENV{BL_SDK_BASE})

set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)

find_package(Threads REQUIRED)

if(Threads_FOUND)
    message(STATUS "Thread Library found ${CMAKE_THREAD_LIBS_INIT}")
    if(CMAKE_USE_PTHREADS_INIT
    target_compile_options(app PRIVATE -pthread)
    target_link_options(app PRIVATE -pthread)
    message(STATUS "Pthread included !")
    else()
    message(WARNING "pthread not included !")
    endif()
endif()

target_link_libraries(app ${CMAKE_THREAD_LIBS_INIT})

sdk_set_main_file(main.c)

project(helloworld)

while I do #include <pthread.h> , I can see the below warning only message during compilation, which end successfully:

/usr/bin/toolchain_gcc_t-head_linux/bin/../lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-unknown-elf/bin/ld: CMakeFiles/helloworld_bl808_m0.elf.dir/main.c.o: in function `main':
/home/ironfist/Documents/Robot/Docs/M1S_Dock/bl808_linux/bouffalo_sdk/examples/helloworld/main.c:117: warning: pthread_create is not implemented and will always fail
/usr/bin/toolchain_gcc_t-head_linux/bin/../lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-unknown-elf/bin/ld: 
/home/ironfist/Documents/Robot/Docs/M1S_Dock/bl808_linux/bouffalo_sdk/examples/helloworld/main.c:122: warning: pthread_join is not implemented and will always fail

Later on, while searching for the reasons, I understood for that to work I will need to compile the code with Linux tool chain instead.

1-Is this correct?

Eventually, I downloaded the toolchain and setup the env. var then upon compilation, I face another issues:

/home/ironfist/Documents/Robot/Docs/M1S_Dock/bl808_linux/bouffalo_sdk/components/libc/newlib/port_memory.c:2:10: fatal error: reent.h: No such file or directory
    2 | #include <reent.h>
      |          ^~~~~~~~~

/home/ironfist/Documents/Robot/Docs/M1S_Dock/bl808_linux/bouffalo_sdk/components/libc/./sys/types.h:20:10: fatal error: _ansi.h: No such file or directory
   20 | #include <_ansi.h>
      |          ^~~~~~~~~

Which I assume it's due to the difference between the elf (Newlib) & linux (libc) tool chain.

2 - Is this also correct?

Probably I missed updating configuration in the make files or compilation flags,

3-Can you please explain to me how to properly migrate into the linuxtool chain in this case?

"Unable to mount root fs"

Heya,

I'm by no means an expert in compiling or with the BL808 in general and I'm stuck on the following error message after booting up my M1s Dock for the first time:

[    0.155415] VFS: Cannot open root device "mtdblock0" or unknown-block(0,0): error -19
[    0.155905] Please append a correct "root=" boot option; here are the available partitions:
[    0.156422] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[    0.156936] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.10.4 #1
[    0.157304] Call Trace:
[    0.157498] [<ffffffe000202810>] walk_stackframe+0x0/0xaa
[    0.157850] [<ffffffe000570276>] show_stack+0x32/0x3e
[    0.158179] [<ffffffe000572308>] dump_stack+0x72/0x8c
[    0.158505] [<ffffffe000570484>] panic+0xfc/0x2aa
[    0.158810] [<ffffffe0000021a8>] 0xffffffe0000021a8
[    0.159123] [<ffffffe0000022b6>] 0xffffffe0000022b6
[    0.159436] [<ffffffe0000023f6>] 0xffffffe0000023f6
[    0.159749] [<ffffffe000001dae>] 0xffffffe000001dae
[    0.160071] [<ffffffe000575612>] kernel_init+0x12/0xf8
[    0.160404] [<ffffffe0002012be>] ret_from_exception+0x0/0xc
[    0.160776] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) ]---

I've followed the steps in the guide and everything went fine when it comes to flashing. I've also used the switch_to_m1sdock.sh script before compiling the firmware.
What could I have done wrong? I also enabled the "Erase Flash" option in Dev Cube to erase the old Linux that was on there.

Thanks already for your help!

SPI drivers

Is it possible to add SPI drivers? I also want to use SPI to CAN drivers in this chip.

Compatibility with Ox64

Hey. Apologies if this is a stupid question.

First of all - is this software compatible with Pine Ox64 boards?

I have managed to follow the instructions and flash all parts of the built software to my Pine Ox64, however I am unsure where the console is outputting to - I have tried all the TX/RX combinations listed on this graphic https://wiki.pine64.org/images/2/24/Ox64_pinout.png with no joy.

Thanks thanks thanks for your answer

Matter Thread support

Can the BL808 support Matter Thread simultaneously with Wifi? The problem with Matter Thread is that the 802.15.4 radio has to be dedicated and listening all of the time, other vendors have tried to share Wifi/BLE/802.15.4 hardware and could not get it functioning within the Matter spec rules.

CAN support

Am exploring BL808. Is it possible to add SPI to CAN support by including MCP2518FD drivers in net/can?

Toolchain URL broken

Toolchain URL provided in the README is broken.

$ wget https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1663142514282/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1-20220906.tar
--2024-02-29 20:34:27--  https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1663142514282/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1-20220906.tar                                                    
Resolving occ-oss-prod.oss-cn-hangzhou.aliyuncs.com (occ-oss-prod.oss-cn-hangzhou.aliyuncs.com)... 47.110.177.19                                                                                                    
Connecting to occ-oss-prod.oss-cn-hangzhou.aliyuncs.com (occ-oss-prod.oss-cn-hangzhou.aliyuncs.com)|47.110.177.19|:443... connected.                                                                                
HTTP request sent, awaiting response... 404 Not Found                                                                                                                                                               
2024-02-29 20:34:30 ERROR 404: Not Found.                                                                                                                                                                           

$ curl https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1663142514282/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1-20220906.tar.gz | tar xz -C toolchain/linux_toolchain/ --strip-components=1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (35) OpenSSL SSL_connect: Connection reset by peer in connection to occ-oss-prod.oss-cn-hangzhou.aliyuncs.com:443 

gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now

But the following works in my end,

wget 'https://datashare.ed.ac.uk/bitstream/handle/10283/4835/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1-20220906.tar.gz?sequence=4&isAllowed=y'

This also breaks the buidroot building.

creating a folder or file

I have problems creating a file, I get the following message.

[@Linux root]#mkdir jc
mkdir: can't create directory 'jc': Read-only file system
[@Linux root]#

[Question] How to program low_load d0/m0 by command line?

whole image can be programmed by 'bflb-iot-tool' by:

bflb-iot-tool --chipname bl808 --interface uart --port /dev/ttyUSB1 --baudrate 2000000 --firmware [email protected] --addr 0xD2000 --single

Update : To program low_load firmwares, bf-mcu-tool need to be patched as : bouffalolab/bouffalo_sdk#115 (comment)

[Question 1] How to program low_load by command line?

From the log of BLDevCube,

It seems latest 'bflb-mcu-tool' do not support groups and generate 'bootinfo_group0.bin' and 'bootinfo_group1.bin', also can not program 2 firmwares in one time.

[Question] Does such a Linux support a command line?

I just got a Sipeed Maix M1s board and flashed Linux to it according to this instruction. All I got from the standard USB serial port was:
"dynamic memory init success,heap size = 156 Kbyte
E907 start...
mtimer clk:1000000
psram clk init ok!"
Is there a possibility to use a command line with such a compact version of Linux? Thank you in advance for your help

FYI - Kernel/Buildroot effort

HI All,
Just opening this issue here to let people know we have got a updated kernel (6.2-rc2) with SD card support and a new buildroot/low_load drivers.

There is a combined effort to get more peripherals, u-boot and so forth happening in the OpenBouffalo Organisation and Pine64 community (please join the #ox64-nutcracker channel on the pine64 community if you want to join in with us).

You can grab a updated image/buildroot etc from here: https://github.com/openbouffalo/buildroot_bouffalo

This should work for both the OX64 and Sipeed boards.

Checked in binaries for bflb_iot_tool, bflb_mcu_tool, genromfs, and openocd

https://github.com/bouffalolab/bl808_linux/tree/main/bl_mcu_sdk_bl808/tools/bflb_flash_tool

has binaries checked in for . This is clearly a mistake as it'll never work on ChromeOS, Raspberry Pi, MacOS, self-hosting, or lots of other environments used by the kinds of people working with this kind of code.

PLEASE check in the source, not the binaries.

JLink has similar issues, but that might not be totally up to you. You should at least link out to the Segger page so people can download the "right" JLink.

Please. Just look in the tree for anything with dll, exe, or similar platform-specific artificacts. This bugreport applies to all of them.

bl_mcu_sdk_bl808
is another checked in binary. Source, pelase.

Also, the capitalization inside https://github.com/bouffalolab/bl808_linux/tree/main/bl_mcu_sdk_bl808/drivers/bl808_driver/risc-v is weird. Common convention is to not use upper case in filenames.

UART console change pins

Hello,

I just compiled and flashed everything on my SiPeed M1S dock. However I cannot get any UART console. On the second enumerated UART I see the following after pressing the reset button:

dynamic memory init success,heap size = 156 Kbyte
E907 start...
mtimer clk:1000000
psram clk init ok!

I can see the linux console output on IO8 (as stated in the docs) but I cannot do anything with it as IO5 is not exposed on the SiPeed M1S dock. I therefore want to change the console (C906) pins to IO17(RX)/IO16(TX) so that it corresponds to the first enumerated USB serial port on the SiPeed M1S dock.

Therefore I changed the serial block in the hw808c.dts to:

serial@30002000 {
			compatible = "bflb-uart,uart0";
			reg = <0x0 0x30002000 0x0 0x1000>;
			interrupt-parent = <&intc>;
			interrupts = <20>;
			clocks = <&mm_xclk>;
			clock-frequency = <40000000>;
			clock-names = "baudclk";
			status = "okay";
			pin {
				rx = <17>;
				tx = <16>;
			};
		};

I than removed the build output in the out directory and reflashed. However nothing has changed. Can anyone give me some pointers?

Kind regards,
Daan

Load access fault on C906 during boot

Board Ox64, used the c906.config defconfig, compiled and flashed according instructions, sadly, after few seconds, C906 crashes as follows (E907 is OK):

Due having limited time for this, I can't play with JTAG and getting more information right now.
Please, any suggestions where I might do a mistake?

dynamic memory init success,heap size = 26 Kbyte 
C906 start...
mtimer clk:1000000
linux load start... 
len:0x006df29f

Un-handled Exception on CPU 1:
mstatus = 0x, FS=8403200, MPP=1, MPIE=3
mcause: 5, mtval = 0x, mepc = 0x

Load access fault

ra = 0x  sp = 0x  gp = 0x  tp = 0x  
t0 = 0x  t1 = 0x  t2 = 0x  t3 = 0x  
t4 = 0x  t5 = 0x  t6 = 0x  
a0 = 0x  a1 = 0x  a2 = 0x  a3 = 0x  
a4 = 0x  a5 = 0x  a6 = 0x  a7 = 0x  
s0 = 0x  s1 = 0x  s2 = 0x  s3 = 0x  
s4 = 0x  s5 = 0x  s6 = 0x  s7 = 0x  
s8 = 0x  s9 = 0x  s10 = 0x s11 = 0x  

Fail to flash final image

During flashing whole_image_linux.bin, it fails on the end during checksum check (BFLB_FLASH_LOAD_VERIFY_FAIL).
I tried 2 000 000 baudrate, also 115 200, but always failed. We use 25Q16JWSIQ, so it should be enough, also the whole_image_linux.bin is under 8 MB.

I think it might be somehow related to #4 , as maybe I used wrong config, which produced bigger Linux image, thus not fitting to SPI Flash.

EDIT: I again forgot it's 16Mbit not 16MB, so of course I can't fit 8MB firmware to 2MB flash... Sorry! :D

device tree compilation warnings.

The device tree compiler (dtc 1.6.1) gives the following warnings:

==================== build dtb =====================
/home/bram/src/bl808_linux/bl808_dts/hw808c.dts:51.21-56.5: Warning (simple_bus_reg): /soc/mm-clock: missing or empty reg/ranges property
/home/bram/src/bl808_linux/bl808_dts/hw808c.dts:58.12-62.5: Warning (simple_bus_reg): /soc/pmu: missing or empty reg/ranges property
/home/bram/src/bl808_linux/bl808_dts/hw808c.dts:24.36-28.6: Warning (interrupt_provider): /cpus/cpu@0/interrupt-controller: Missing #address-cells in interrupt provider
/home/bram/src/bl808_linux/bl808_dts/hw808c.dts:38.39-49.5: Warning (interrupt_provider): /soc/interrupt-controller@e0000000: Missing #address-cells in interrupt provider

git clone this project has been problem

Today I git clone this project ,but have been problem.
Bacause finally git clone this project,output error:error: invalid path 'linux-5.10.4-808/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c' fatal: unable to checkout working tree warning: Clone succeeded, but checkout failed. You can inspect what was checked out with 'git status' and retry with 'git restore --source=HEAD :/'
This error was represent iI haven`t sufficient access permissions and ensuring the repository's status is correct.
0306

SD-Card not working.

I have enabled in the kernel:

  • CONFIG_BLK_DEV_SD
  • CONFIG_MMC_CQHCI
  • CONFIG_MMC_MTK
  • CONFIG_VFAT_FS

But there is no /dev/mm* entry.

What is required to get SD-Cards working?

I see SDH is hooked up the GPIO0/1/2/3/4/5. Where do I get a driver for it?

Python script merge_7_5Mbin.py not found

I'm trying to compile whole binary by running build.sh all, however in the last step the script complains that merge_7_5Mbin.py is not found:

image

Please upload this script for merging binary, thanks🤤

GPIO

Is GPIO access available?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.