Skip to content
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

Bluepill template built with arm-gcc does not fit 128K Flash #139

Closed
Chandler-Kluser opened this issue May 29, 2022 · 9 comments
Closed

Comments

@Chandler-Kluser
Copy link

I have got the bluepill template for pikascript and then made a Makefile to compile with arm-none-eabi-gcc, the code is in this repository.

I was able to compile all .c files in the template into objects and them link them successfully, I could also build a binary firmware.

The issue is that the size is WAY too big for 128K bluepill flash memory, so I would like to know what objects may not be compiled to build a smaller binary.

Thanks in advance!

@pikasTech
Copy link
Owner

pikasTech commented May 30, 2022

maybe you can add the -Os option for size optimization.

https://github.com/pikasTech/pikascript/blob/562550dce02351b58f072f248fc79f23e7b331b7/bsp/stm32f103c8/Makefile#L25

@Chandler-Kluser
Copy link
Author

I believe it has fitted, but not sure because my STM32 is 64K:

arm-none-eabi-size bin/firmware.elf
   text    data     bss     dec     hex filename
 122660     492   19440  142592   22d00 bin/firmware.elf

@pikasTech
Copy link
Owner

I'm trying to use the STM32CUBEMX auto-generated makefile to fix that.

For more details:

https://github.com/Chandler-Kluser/pikascript_gcc_bluepill/pull/1

@Chandler-Kluser
Copy link
Author

Compiled with the merge request you made, I have got:

arm-none-eabi-size obj/stm32f103c8.elf
   text    data     bss     dec     hex filename
  57264     484   18980   76728   12bb8 obj/stm32f103c8.elf

It would be great if there was ANYTHING that could be not used to make it fit in 64kB, but it worked in my PC!

I will also improve the Makefile you did, thanks a lot!

@Chandler-Kluser
Copy link
Author

I remember a week ago if we commented the line:

import STM32F103

in main.py and recompile with pikascript compiler and then build the entire image again we could make the image fit in 64kB, but I am not finding that anymore in this new template.

@pikasTech
Copy link
Owner

I remember a week ago if we commented the line:

import STM32F103

in main.py and recompile with pikascript compiler and then build the entire image again we could make the image fit in 64kB, but I am not finding that anymore in this new template.

the STM32F103 is imported by mchine.pyi now.

@pikasTech pikasTech mentioned this issue May 30, 2022
@Chandler-Kluser
Copy link
Author

I did comment mchine.pyi file, recompiled that with pikascript compilar and then build the project again.

But the image did not get smaller, do you have any idea?

@pikasTech
Copy link
Owner

I did comment mchine.pyi file, recompiled that with pikascript compilar and then build the project again.

But the image did not get smaller, do you have any idea?

the 57k image is after commend the machin.py file.

if not commend the machin.pyi, the imagesize would be 71K

root@32d1708ead1f:~/pikascript_gcc_bluepill# ll bin/stm32f103c8.bin -h
-rwxr-xr-x 1 root root 71K May 30 11:30 bin/stm32f103c8.bin*

@Chandler-Kluser
Copy link
Author

Great, thanks a lot!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants