-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
L4 integration: Added new lines for building for l4 series. #1904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
If this is the only location where 64-bit integer arith is used, then it would be good to find an alternative. For example, pre-dividing the clock by 8 and post-multiplying the answer by 8 should work. |
34af761
to
a838aae
Compare
I modified stm32l4xx_hal_uart.h in the way you proposed and therefore removed the inclusion of libgcc in the stm32l4 build. With a little python program I calculated the devision of the calculations: This modification is put in a separate commit to see the changes done to the vanilla HAL (as proposed by dhylands). |
If the maximum for PCLK is 80MHz, would it be better to do |
|
This is not a good solution, we don't want to lose precision like this. The BRR register is actually only 20-bits wide, and one can write a custom division routine, something like: uint32_t div = pclk / 0x1000000 + 1;
pclk /= div;
baud /= div;
brr = 256 * pclk / baud; // won't overflow This code removes a common factor between pclk and baud before doing the large division. For pclk=80MHz it'll divide the two variables through by 5, which is enough to make sure 256 * pclk doesn't overflow an unsigned 32-bit int. |
Solution which works for any frequency from 32768...4294967295 (2**32-1) is checked in to #1890. |
9167980
to
1cc81ed
Compare
Merged in 69f26c6. |
Bump circuitpython-stage to 1.0.2
This is the 4th PR in a series of PR to support the STM32L4 series in micropython. (see http://forum.micropython.org/viewtopic.php?f=12&t=1332&sid=64e2f63af49643c3edee159171f4a365)
I add the modifications to the Makefile to support the build of the new platform. I had to add the inclusion of the libgcc as on line 965 of the stm32l4xx_hal_uart.h there is a division with 64bit parameter (Macro UART_DIV_LPUART). The PCLK can be the system clock which is on L4 up to 80MHz. Multiply 80MHz by 256 is larger than 2**32. Is there a better way to solve this problem?
Including libgcc still gives link error:
arm-none-eabi-ld: warning: /usr/lib/gcc/arm-none-eabi/4.9.3/armv7e-m/fpu/libgcc.a(bpabi.o) uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail
arm-none-eabi-ld: warning: /usr/lib/gcc/arm-none-eabi/4.9.3/armv7e-m/fpu/libgcc.a(_divdi3.o) uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail
arm-none-eabi-ld: warning: /usr/lib/gcc/arm-none-eabi/4.9.3/armv7e-m/fpu/libgcc.a(_udivdi3.o) uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail
How can this be solved?