Closed mahyar1284 closed 1 year ago
I can add support for stm32h7.
What stm32h7 devboard do you use?
I can add support for stm32h7.
What stm32h7 devboard do you use?
CoreH743I board from Waveshare https://www.waveshare.com/coreh743i.htm it has onboard 8MB SDRAM if I learn how to add board support to barebox, then I can add support for stm32h7 discovery and evaluation boards too.
U-boot, supports stm32 families .. it has onboard 8MB SDRAM
Oh, it can run linux. I see it in https://github.com/torvalds/linux/blob/master/arch/arm/mach-stm32/Kconfig You can get necessary drivers from linux.
if I learn how to add board support to barebox, then I can add support for stm32h7 discovery and evaluation boards too.
Can you please make very simple self-hosting baremetal hello world program for STM32H7 (use asm or C, no matter). Something like https://github.com/frantony/riscv-nmon.
I can take your hello world for STM32H7 and submerge it into barebox build infrastructure. Next we can add debug_ll methods and adapt arch/arm stuff for Cortex-M7 (most code can be stolen from linux and/or U-Boot).
@frantony Sure I can. So, I should only write a simple C or assembly program to init the clock and USART and a simple command line over serial. right?
@mahyar1284
Sure I can. So, I should only write a simple C or assembly program to init the clock and USART and a simple command line over serial. right?
Yes. The program should work on your real hardware.
@frantony
Yes. The program should work on your real hardware.
Can I use CMSIS and arm header file that contains the address of stm32h743 registers that is provided by st? or I should define all registers by myself?
Can I use CMSIS and arm header file that contains the address of stm32h743 registers that is provided by st?
It is temporary solution so you can use any code and any header files. Please, no software licensing violations! But ... I prefer something lightweight, e.g. libopencm3.
At the moment libopencm3 supports STM32H7.
I suppose we can start with https://github.com/libopencm3/libopencm3-miniblink.
Next the uart example for stm32f4 can be adapted for stm32h7.
Just for your information, the stm32mp1 is supported by barebox. It shares some peripherals with the stm32h743 for which there are already barebox drivers:
st,stm32f7-uart
arm,pl18x
(SD/MMC)st,stm32-rcc
(reset controller)st,stm32f7-i2c
st,stm32-timer
(MFD with PWM)Would be cool to see this used for the original MCU as well. Best of luck!
@mahyar1284
I have just adapted libopencm3 usart-and-led example for barebox, please see https://github.com/frantony/barebox/tree/20200823.stm32 Instruction on building code and uploading image into MCU's SRAM please see in the top commit message.
Original libopencm3 example: https://github.com/libopencm3/libopencm3-examples/blob/master/examples/stm32/f4/stm32f429i-discovery/usart/usart.c
Unrolled code with no libopencm3 dependencies: https://github.com/frantony/barebox/commit/6f87df4f687a8de91acc4564a59662f7ba42748d#diff-283f6bea1a938fb3d81fa7ee94866e71R257
Please try to adapt it for STM32H7.
O... i see you love exotic types of pain :) This weekend i started to port barebox to pic32mz :)
@frantony first off, thank you so much for helping me. But as I mentioned in my first comment, unfortunately I don't know how Barebox works and I have no information about the infrastructure of barebox. and I'm just a teenager who learned programming by himself. and I'm newbie in opensource programming. but I always trying to learn. And I've read the datasheet of stm32h7 and I learned how to control most of its peripherals directly using its registers (In ARM Keil ide). But I'd be happy to learn the Barebox infrastructure. Please give me a guide about Barebox infrastructure. Thanks.
I know the most registers and control flow of stm32h7 peripherals and even I've written some of its peripheral drivers in bare-metal. but I don't know anything about barebox driver model and I don't know how barebox reads the device properties from device tree. if there is any tutorial about writing barebox drivers, I can follow it to support for stm32h7.
No one will spend a second on writing architecture of something. Almost each book on writing kernel driver was outdated a printing time and useless now. Learn by reading, braking and making the code. To make it easier, try with barebox sandbox: https://www.barebox.org/doc/latest/boards/sandbox.html
@mahyar1284
Learn by reading, braking and making the code.
@olerem is right. There is no exhaustive guide about Barebox infrastructure.
If you want to master barebox you have to run barebox in very many different situations very very many times. No guide can teach you barebox in all its minutest details. But you can teach yourself by doing. Don't try to learn barebox, but try to solve your problems with barebox.
First of all, git is your best friend! git actually is an essential component of barebox developing process. With git you can easely consult how to add piece of code to barebox. Use git to understand how barebox was evolved!
Next your friend is qemu. Qemu makes it possible to run barebox on ARM or MIPS emulated board. You can examine barebox execution with gdb instruction by instruction!
I recommend you to do several simple exercises with qemu:
build and run barebox on emulated mips malta board with gdb
run non-x86 Debian under QEMU
Also you can't hack barebox without understanding device tree concepts. I recommend you this brilliant presentation by Thomas Petazzoni:
Barebox inherits very many concepts from linux kernel, so gaining experience in barebox you are gaining experience in linux kernel too.
No one will spend a second on writing architecture of something. Almost each book on writing kernel driver was outdated a printing time and useless now. Learn by reading, braking and making the code.
Dear Oleksij (@olerem) and Antony (@frantony) First off, thank you so much for helping me. But understanding a big project like barebox or linux kernel only by reading the code is really time consuming (specially for newbies like me). It would be much better if we as a Barebox community, document our project completely.
So, by intensifying the perspective of developers toward the Barebox infrastructure, we can push the boundaries and turn newbie developers into Barebox contributors and tell them how Barebox can bring security and flexibility to their embedded projects. Let me be clear, Do Not Take This Message Lightly. At the end, it's never too late to trade in your deadly hood traditional life to your lively hood by creating a complete tutorial and documentation of the infrastructure of Barebox. A well-written tutorial and documentation would give us improvement in speed, and is going to impact the development of billions of embedded systems used worldwide. Even more people will contribute to Barebox when they can learn it easier and faster. My mission as a developer and more than that, as a person, is to empower every student and every developer to come up with new tech capabilities, not wasting their time to understand the project after months of reading the source code.
when I learned Barebox, I'll be happy to spend a lot of time on writing docs and tutorials to help newbies and accelerating the growth of Barebox community, and I keep my words. because I'm determined to make a giant stride toward technology to amplify human ingenuity.
PS: We should update tutorials and documents continuously while updating and adding features to the source code. A well-documented project is much more successful.
Thanks.
@frantony thank you so much. It's really helpful and now I'm reading it and trying to understand it better. Now I made some changes to it and want to run and debug it on my stm32h7 board hardware. for flashing I use .bin file but for using GDB and openocd to debug it, I need a file with .elf format. how can I generate .elf file of barebox? (even for debugging in qemu I need .elf file)
@mahyar1284
I need a file with .elf format. how can I generate .elf file of barebox?
The file barebox
is an ELF-file, e.g.
barebox$ file barebox
barebox: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
FWIW, there's a section on barebox development in the manual now: https://www.barebox.org/doc/latest/devel/devel.html with pointers on how to port barebox.
If you still need help to get barebox running, here's my patches to get it working on stm32f4: https://github.com/a3f/barebox/commits/stm32f4-doom I've not found the time yet to clean them up for upstreaming. You're certainly welcome to do so.
As this is not a bug, we'll close this issue. Feel free to reach out on mailing list or IRC/Matrix if you need assistance.
I know the most registers and control flow of stm32h7 peripherals and even I've written some of its peripheral drivers in bare-metal. but I don't know anything about barebox driver model and I don't know how barebox reads the device properties from device tree. if there is any tutorial about writing barebox drivers, I can follow it to support for stm32h7. other bootloaders e.g. U-boot, supports stm32 families (e.g., stm32f4, stm32f7, stm32h7). Actually, barebox is a great bootloader but It would be better if it supports more SOCs.