4ms / stm32mp1-baremetal

Baremetal framework and example projects for the STM32MP15x Cortex-A7 based MPU
Other
153 stars 28 forks source link

Add hal_lib example #3

Closed cody84 closed 3 years ago

cody84 commented 3 years ago

Example initializes HAL Library and adds system calls for printf.

danngreen commented 3 years ago

Thanks! printf support will be nice to have. I'll test this out on hardware tomorrow. In the mean time I've got a few comments, I'll leave them in the Commits section by the relevant lines of code.

cody84 commented 3 years ago

I have been using an old clone of your repo from early July (maybe older), so you may have updated some things that I didn't catch. I don't recall making those changes to makefile-common.mk. I did try removing -nostdlib from CFLAGS and LFLAGS in shared/makefile-common.mk of your current repo and was able to compile and run with no errors.

danngreen commented 3 years ago

I have been using an old clone of your repo from early July (maybe older), so you may have updated some things that I didn't catch. I don't recall making those changes to makefile-common.mk. I did try removing -nostdlib from CFLAGS and LFLAGS in shared/makefile-common.mk of your current repo and was able to compile and run with no errors.

Ah, ok that explains it! I tested in on an STM32MP1 Discovery board, which has a red and green LED at the same port/pins as the LEDs on the MYIR board. Works great on the Disco board too. I'd like to add this info to the README, that it works with either board.

The only thing I noticed is that the letter 'C' that startup.s tries to print ends up getting clobbered because the UART is re-initialized in main before the peripheral can finish sending data. So on my Disco board I see:

AB�
Hello from HAL Driver!

I added a HAL_Delay(1) right before the UART is initialized, which does the trick.

danngreen commented 3 years ago

I'm not sure the best way to add commits to a PR on github, so I'm just going to merge this and then apply the changes I mentioned (README, HAL_Delay, and makefile-common stuff).

danngreen commented 3 years ago

Also-- since I'm editing the README... do you want credit in there? Right now it gives credit to other project. Let me know if and how you'd want to be credited for this project.

And again, thanks for this contribution!

cody84 commented 3 years ago

Good catch on the 'C'. I overlooked that. No need to mention me in the README. Thank you.