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

source/Makefile: add HOST_PYTHON, extend clean target, remove -.d generation #1701

Merged
merged 5 commits into from Jun 14, 2023

Conversation

ia
Copy link
Collaborator

@ia ia commented Jun 14, 2023

Set of changes:

  • add HOST_PYTHON variable for flexibility of environment setup
  • extend clean target to make source directory as new
  • rename -.d autogenerated temp file
  1. Add HOST_PYTHON variable for flexibility of environment setup.

Without patch on some environments:

source$ make model=TS80P firmware-EN
Building for Miniware 
Building file: ./Startup/startup_stm32f103t8ux.S
[skip log]
Generating translations for language EN
Traceback (most recent call last):
  File "../Translations/make_translation.py", line 21, in <module>
    import font_tables
  File "/media/ia/DATA/data/devel/ironOS/fork/Translations/font_tables.py", line 1, in <module>
    from typing import Dict, Final, Tuple
ImportError: cannot import name 'Final'
Makefile:654: recipe for target 'Core/Gen/Translation.EN.cpp' failed
make: *** [Core/Gen/Translation.EN.cpp] Error 1

Final has been implemented in Python starting from v3.8. Some systems provide Python 3.8 but not as python3. So instead of messing with environment, this patch implements variable for providing custom version. After the patch:

source$ make HOST_PYTHON=python3.8 model=TS80P firmware-EN
Building for Miniware 
[skip log]
INFO:root:Done
Linking Hexfile/TS80P_EN.elf
Memory region         Used Size  Region Size  %age Used
             RAM:       13080 B        20 KB     63.87%
             ROM:       44744 B        46 KB     94.99%
arm-none-eabi-objcopy Hexfile/TS80P_EN.elf -O ihex Hexfile/TS80P_EN.hex
arm-none-eabi-objcopy Hexfile/TS80P_EN.elf -O binary Hexfile/TS80P_EN.bin
arm-none-eabi-size Hexfile/TS80P_EN.elf
   text	   data	    bss	    dec	    hex	filename
  44632	    108	  12984	  57724	   e17c	Hexfile/TS80P_EN.elf
python3.8 dfuse-pack.py -b 0x08004000@0:Hexfile/TS80P_EN.bin -D 0x1209:0xDB42 Hexfile/TS80P_EN.dfu
  1. In addition, this patch extends clean target to make source dir as new.

  2. Also, this patch renames hard-to-remove -.d temp file which seems not to be used during compilation but generated by

arm-none-eabi-gcc -dM -E -D VECT_TAB_OFFSET=0x4000U [skip] -T./Core/BSP/Miniware/stm32f103.ld -c                       - > /media/ia/DATA/data/devel/ironOS/fork/source/Core/Gen/macros.txt

From man gcc (for -MD option) (I had no idea about this myself):

The driver determines file based on whether an -o option is given.  If it is, the driver uses its argument but with a suffix of .d, otherwise it takes the name of the input file, removes any directory components and suffix, and applies a .d suffix.

Since we have input as stdin, hence we get -.d in our directories like a gum glued to shoes. By adding -MF Core/Gen/macros.tmp temp file will be generated where it should.

bash-5.1# ls -lah
total 84K    
drwxrwxr-x    5 1000     1000        4.0K Jun 13 06:58 .
drwxrwxr-x   11 1000     1000        4.0K Jun 12 20:11 ..
-rw-rw-r--    1 1000     1000        3.9K Jun  7 20:22 .clang-format
drwxrwxr-x    9 1000     1000        4.0K Jun 13 06:57 Core
-rw-rw-r--    1 1000     1000       30.8K Jun 13 06:35 Makefile
drwxrwxr-x    3 1000     1000        4.0K Jun  7 20:22 Middlewares
drwxrwxr-x    2 1000     1000        4.0K Jun  7 20:22 Startup
-rwxrwxr-x    1 1000     1000        4.8K Jun  7 20:22 build.sh
-rwxrwxr-x    1 1000     1000       11.7K Jun  7 20:22 dfuse-pack.py
-rwxrwxr-x    1 1000     1000        3.2K Jun  7 20:22 metadata.py
-rw-rw-r--    1 1000     1000         244 Jun  9 03:35 version.h
bash-5.1# make clean && make model=TS80P firmware-EN
[skip]
Building for Miniware 
Building file: ./Startup/startup_stm32f103t8ux.S
[skip]
echo "#include <configuration.h>" | arm-none-eabi-gcc -dM -E -D VECT_TAB_OFFSET=0x4000U -mcpu=cortex-m3 -mthumb -mfloat-abi=soft -I./Core/Inc -I./Core/brieflz -I./Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS -I./Middlewares/Third_Party/FreeRTOS/Source/include -I./Core/Drivers -I./Core/BSP -I./Core/Threads -I./Core/Threads/OperatingModes -I./Core/Threads/OperatingModes/utils -I./Core/Drivers/usb-pd/include -I./Core/BSP/Miniware -I./Core/BSP/Miniware/Vendor/CMSIS/Device/ST/STM32F1xx/Include -I./Core/BSP/Miniware/Vendor/CMSIS/Include -I./Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc -I./Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/Legacy  -Wtrigraphs -Wuninitialized -Wmissing-braces -Wfloat-equal -Wunreachable-code -Wswitch-default -Wreturn-type -Wundef -Wparentheses -Wnonnull -Winit-self -Wmissing-include-dirs -Wsequence-point -Wswitch -Wformat -Wsign-compare -Waddress -Waggregate-return -Wmissing-field-initializers -Wshadow -Wno-unused-parameter -Wdouble-promotion  -Wbad-function-cast -D STM32F103T8Ux -D STM32F1 -D STM32 -D USE_HAL_DRIVER -D STM32F103xB -D USE_RTOS_SYSTICK -D GCC_ARMCM3 -D ARM_MATH_CM3 -D STM32F10X_MD -finline-limit=9999999 -D USE_RTOS_SYSTICK -D MODEL_TS80P -D VECT_TAB_OFFSET=0x4000U -fshort-wchar -Dgcc -MMD -std=gnu11 -Os -fno-jump-tables -foptimize-strlen -faggressive-loop-optimizations -fdevirtualize-at-ltrans -fmerge-all-constants -fshort-wchar -flto -finline-small-functions -finline-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections -fshort-enums -fsingle-precision-constant  -fno-common -fno-math-errno -ffast-math -ffinite-math-only -fno-signed-zeros -fsingle-precision-constant -T./Core/BSP/Miniware/stm32f103.ld -c                       - > /data/fork/source/Core/Gen/macros.txt
Generating translations for language EN
INFO:root:Build version: v2.21.E7BCF92
INFO:root:Making ['EN'] from /data/fork/Translations
INFO:root:Preparing language data for EN
INFO:root:Generating fonts for 62 symbols
INFO:root:Generating fonts for 74 symbols
INFO:root:Generating block for EN
[skip]
INFO:root:Writing pickled data to Objects/TS80P/Core/Gen/translation.files/EN.pickle
INFO:root:Done
Linking Hexfile/TS80P_EN.elf
[skip]
Memory region         Used Size  Region Size  %age Used
             RAM:       13096 B        20 KB     63.95%
             ROM:       43004 B        46 KB     91.30%
arm-none-eabi-objcopy Hexfile/TS80P_EN.elf -O ihex Hexfile/TS80P_EN.hex
arm-none-eabi-objcopy Hexfile/TS80P_EN.elf -O binary Hexfile/TS80P_EN.bin
arm-none-eabi-size Hexfile/TS80P_EN.elf
   text	   data	    bss	    dec	    hex	filename
  42888	    112	  12992	  55992	   dab8	Hexfile/TS80P_EN.elf
python3 dfuse-pack.py -b 0x08004000@0:Hexfile/TS80P_EN.bin -D 0x1209:0xDB42 Hexfile/TS80P_EN.dfu
bash-5.1# ls -lah
total 96K    
-rw-r--r--    1 root     root          57 Jun 13 06:59 -.d
drwxrwxr-x    7 1000     1000        4.0K Jun 13 06:59 .
drwxrwxr-x   11 1000     1000        4.0K Jun 12 20:11 ..
-rw-rw-r--    1 1000     1000        3.9K Jun  7 20:22 .clang-format
drwxrwxr-x   10 1000     1000        4.0K Jun 13 06:59 Core
drwxr-xr-x    2 root     root        4.0K Jun 13 06:59 Hexfile
-rw-rw-r--    1 1000     1000       30.8K Jun 13 06:35 Makefile
drwxrwxr-x    3 1000     1000        4.0K Jun  7 20:22 Middlewares
drwxr-xr-x    3 root     root        4.0K Jun 13 06:58 Objects
drwxrwxr-x    2 1000     1000        4.0K Jun  7 20:22 Startup
-rwxrwxr-x    1 1000     1000        4.8K Jun  7 20:22 build.sh
-rwxrwxr-x    1 1000     1000       11.7K Jun  7 20:22 dfuse-pack.py
-rwxrwxr-x    1 1000     1000        3.2K Jun  7 20:22 metadata.py
-rw-rw-r--    1 1000     1000         244 Jun  9 03:35 version.h
bash-5.1# 

ia and others added 2 commits June 13, 2023 10:14
…ty of environment setup / extend clean target to make source directory as new / rename -.d autogenerated temp file
Copy link
Owner

@Ralim Ralim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I'm rather concerned anyone is running python 3.7 or older now (given <3.7 is already dead, and 3.7 is EOL in less than two weeks). But I see no issue with a python path. :)

However, please dont remove the hexfile folder, the intent is explicit for it to remain to make it easier when your reflashing a Miniware iron a stack of times.

source/Makefile Outdated
rm -Rf Core/Gen
rm -Rf $(OUTPUT_DIR_BASE)
rm -Rf $(HEXFILE_DIR)/*
rm -Rf $(HEXFILE_DIR)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please dont rm the Hexfile folder if we can, it makes it far more annoying as it means file mangers will kick you out (as the folder is gone) or a terminal in the folder will have a broken path.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aaaaha! I haven't thought that it may be useful, sorry-sorry. 😰 Will re-do patch as soon as I can. 👌

Copy link
Collaborator Author

@ia ia Jun 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, wait a minute... I sincerely sorry to bother you, just expressing some suggestion before updating PR - how about adding another one target, something like this right next to clean target:

mrproper / clean-all: clean
    rmdir $(HEXFILE_DIR)

Just curious what do you think about such approach? Thanks.

Update: it's not my stubbornness but tidiness - I just think that it's a good approach to have additional clean[] target cleaning source tree to default state, that's it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean-all would be totally fine by me :) 😁 🤗

I totally get you on having a full cleanup; I probably should throw a comment on it as to why that folder gets left hanging around. It was deliberate, but probably not obvious until one does a few device bring ups 🤣

@Ralim
Copy link
Owner

Ralim commented Jun 14, 2023

Oh, and the odd file never bothered me; but good to have that resolved 😁

@ia
Copy link
Collaborator Author

ia commented Jun 14, 2023

  • updated clean target as suggested to keep Hexfile directory 👍
  • added mrproper target for full clean 😇

@Ralim
Copy link
Owner

Ralim commented Jun 14, 2023

Probably swap mrproper to clean-all to make it more logical to others 🙈
But otherwise love it ❤️

@ia
Copy link
Collaborator Author

ia commented Jun 14, 2023

Probably swap mrproper to clean-all to make it more logical to others see_no_evil But otherwise love it heart

No problem. Was debating over the target name anyway myself. Thanks for resolving. 🤭

@Ralim Ralim enabled auto-merge (squash) June 14, 2023 12:34
@Ralim Ralim merged commit 5b1c273 into Ralim:dev Jun 14, 2023
11 checks passed
@Ralim
Copy link
Owner

Ralim commented Jun 14, 2023

Thank you for the help with this 🙇🏼
Always appreciate the help.

@ia
Copy link
Collaborator Author

ia commented Jun 14, 2023

Thank you for the help with this 🙇🏼
Always appreciate the help.

It's my pleasure & honor to finally commit back at least something useful for this amazingly useful and incredibly awesome project. 🙏

@ia ia deleted the dev-mk branch June 15, 2023 19:22
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

Successfully merging this pull request may close these issues.

None yet

2 participants