py32duino / Arduino-PY32

Arduino core for the PY32.
MIT License
43 stars 8 forks source link

"This header is not available in freestanding mode." #2

Closed NoNamedCat closed 11 months ago

NoNamedCat commented 11 months ago

描述一下这个bug / Describe the bug

when I try to compile the simple "blink" program the output says:

.arduino15/packages/PY32Duino/tools/xpack-arm-none-eabi-gcc/13.2.1-1.1/arm-none-eabi/include/c++/13.2.1/bits/requires_hosted.h:34:4: error: #error "This header is not available in freestanding mode." 34 | # error "This header is not available in freestanding mode."

复现步骤 / To Reproduce

v0.1.1 System: Linux Mint

如果正常,应该是什么样 / Expected behavior

Compile the sketch.

截图 / Screenshots

image

日志 / Logs

.arduino15/packages/PY32Duino/tools/xpack-arm-none-eabi-gcc/13.2.1-1.1/arm-none-eabi/include/c++/13.2.1/bits/requires_hosted.h:34:4: error: #error "This header is not available in freestanding mode." 34 | # error "This header is not available in freestanding mode."

系统 / System

Mint 22.04

PACK包版本 / Version

0.1.1

验证

HalfSweet commented 11 months ago

Fixed in 0.1.2

NoNamedCat commented 11 months ago

Tks HalfSweet

NoNamedCat commented 11 months ago

Sorry. With the 0.1.2 i have this issue:

WARNING: library SrcWrapper claims to run on AirMCU architecture(s) and may be incompatible with your current board which runs on PY32 architecture(s). In file included from /home/nigrum/.arduino15/packages/PY32Duino/hardware/PY32/0.1.2/system/PY32F0xx/py32f0xx_hal_conf_default.h:220, from /home/nigrum/.arduino15/packages/PY32Duino/hardware/PY32/0.1.2/system/PY32F0xx/py32f0xx_hal_conf.h:13, from /home/nigrum/.arduino15/packages/PY32Duino/hardware/PY32/0.1.2/system/Arduino-PY32F0xx-Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal.h:33, from /home/nigrum/.arduino15/packages/PY32Duino/hardware/PY32/0.1.2/system/Arduino-PY32F0xx-Drivers/CMSIS/Device/PY32F0xx/Include/py32f0xx.h:195, from /home/nigrum/.arduino15/packages/PY32Duino/hardware/PY32/0.1.2/cores/arduino/py32/py32_def.h:26, from /home/nigrum/.arduino15/packages/PY32Duino/hardware/PY32/0.1.2/cores/arduino/py32/clock.h:19, from /home/nigrum/.arduino15/packages/PY32Duino/hardware/PY32/0.1.2/cores/arduino/wiring_time.h:23, from /home/nigrum/.arduino15/packages/PY32Duino/hardware/PY32/0.1.2/cores/arduino/wiring.h:38, from /home/nigrum/.arduino15/packages/PY32Duino/hardware/PY32/0.1.2/cores/arduino/Arduino.h:36, from /tmp/arduino/sketches/2C45634B9C38D38B552DD500A30E66FE/sketch/sketch_dec1a.ino.cpp:1: /home/nigrum/.arduino15/packages/PY32Duino/hardware/PY32/0.1.2/system/Arduino-PY32F0xx-Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_dma.h:116:3: error: 'DMA_Channel_TypeDef' does not name a type; did you mean 'DMA_InitTypeDef'? 116 | DMA_Channel_TypeDef Instance; /!< Register base address / | ^~~~~~~ | DMA_InitTypeDef /home/nigrum/.arduino15/packages/PY32Duino/hardware/PY32/0.1.2/system/Arduino-PY32F0xx-Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_dma.h:136:3: error: 'DMA_TypeDef' does not name a type; did you mean 'TIM_TypeDef'? 136 | DMA_TypeDef DmaBaseAddress; /!< DMA Channel Base Address / | ^~~ | TIM_TypeDef In file included from /home/nigrum/.arduino15/packages/PY32Duino/hardware/PY32/0.1.2/system/PY32F0xx/py32f0xx_hal_conf_default.h:284: /home/nigrum/.arduino15/packages/PY32Duino/hardware/PY32/0.1.2/system/Arduino-PY32F0xx-Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_rtc.h:173:3: error: 'RTC_TypeDef' does not name a type; did you mean 'RCC_TypeDef'? 173 | RTC_TypeDef Instance; /!< Register base address */ | ^~~ | RCC_TypeDef /home/nigrum/.arduino15/packages/PY32Duino/hardware/PY32/0.1.2/cores/arduino/py32/backup.h: In function 'void resetBackupDomain()': /home/nigrum/.arduino15/packages/PY32Duino/hardware/PY32/0.1.2/system/Arduino-PY32F0xx-Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_rcc.h:1251:60: error: 'RCC_BDCR_BDRST' was not declared in this scope 1251 | #define HAL_RCC_BACKUPRESET_FORCE() SET_BIT(RCC->BDCR, RCC_BDCR_BDRST) | ^~~~~~ /home/nigrum/.arduino15/packages/PY32Duino/hardware/PY32/0.1.2/system/Arduino-PY32F0xx-Drivers/CMSIS/Device/PY32F0xx/Include/py32f0xx.h:170:42: note: in definition of macro 'SET_BIT' 170 | #define SET_BIT(REG, BIT) ((REG) |= (BIT)) | ^~~ /home/nigrum/.arduino15/packages/PY32Duino/hardware/PY32/0.1.2/cores/arduino/py32/backup.h:71:3: note: in expansion of macro 'HAL_RCC_BACKUPRESET_FORCE' 71 | __HAL_RCC_BACKUPRESET_FORCE(); | ^~~~~~~

exit status 1

Compilation error: exit status 1

HalfSweet commented 11 months ago

What development board model did you choose?

NoNamedCat commented 11 months ago

PY32F002

NoNamedCat commented 11 months ago

When I choose the PY32F030 i have another problem:

WARNING: library SrcWrapper claims to run on AirMCU architecture(s) and may be incompatible with your current board which runs on PY32 architecture(s). /home/nigrum/.arduino15/packages/PY32Duino/tools/xpack-arm-none-eabi-gcc/13.2.1-1.1/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld: /tmp/arduino/sketches/2C45634B9C38D38B552DD500A30E66FE/sketch_dec1a.ino.elf section ._user_heap_stack' will not fit in regionRAM' /home/nigrum/.arduino15/packages/PY32Duino/tools/xpack-arm-none-eabi-gcc/13.2.1-1.1/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld: region `RAM' overflowed by 304 bytes collect2: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

This is with the blink example.

HalfSweet commented 11 months ago

When choosing the F003 or F030 models with 2k RAM, it is possible that the linker will complain about not having enough RAM space. This problem is due to the fact that the framework takes up too much of it... and the main Serial library takes up quite a bit.

We can switch to the Disabled (no Serial support) option in the U(S)ART support settings, or modify the buffer size by manual injection, which will help solve the problem.

HalfSweet commented 11 months ago

In version 0.1.3, PY32F002A should compile properly.

Feel free to contact me if you have any problems with the runtime, and any comments you can make about this project would be greatly appreciated.

garudaonekh commented 11 months ago

Yes, it works with PY32F002 now.

NoNamedCat commented 11 months ago

I don't want to open a new issue for this question HalfSweet. Forgive me if posting this question here is wrong. I will delete it if so. Do you have info about the py32f002 and its ram? The datasheet says something about it, but in reality it has 4kb of ram. I have many boards (I purchased the chips on LCSC) and all of the chips report 4kb of ram instead of the 3kB of static RAM that the datasheet says. All the people on forums have the same behavior on the chips (Seems that the silicon inside is the same as the PY32F030x6(32KB Flash/4KB RAM), in fact in many forums they said that is possible to use the py32f002 as a py32f030x6 without a problem. Is really confusing to me all of this. If I want to design a product with this IC obviulsy is recommended to follow the datasheet and the specs. But why they use a more complete silicon and sell the chips with a lower price? Also... the py32f series is a clone of the AirMCU family?

HalfSweet commented 11 months ago

It's a hard one to average out, maybe the chip makers will use the same core inside multiple chips with different labeling for their own profit maximization or to reduce inventory, which might lead us to misunderstandings about the overall product.

But in any case, this repository will follow the datasheet and you can choose another model if you need to, in theory this will not be a problem.

Both AirMCU and PY32Duino are maintained by me, including OpenPuya in the future, but these are two different companies and eventually there may be some features that will not be fully synchronized.

Finally, thanks for your love of this project, and if you run into any problems, feel free to ask!

NoNamedCat commented 11 months ago

I found another company making the same chip? The datasheet is very similar with the specs of the IC. I have to translate and read it. But for me sound like it is the same. https://www.lcsc.com/product-detail/Microcontroller-Units-MCUs-MPUs-SOCs_Geehy-APM32F003F6P6_C2975251.html

NoNamedCat commented 11 months ago

Here is the schematic for a board that I'm designing. What do you think? Are you interested on the design? PY-CAT-002

HalfSweet commented 11 months ago

Sorry, I'm not familiar with Geehy as a company.

But it's not surprising for a Cortex-M core processor to have similar or even the same peripheral IP, so if it really doesn't differ much from the py32, maybe I can add it to this project.

NoNamedCat commented 11 months ago

I grabbed the bootloader part from your design. Here is the render of the board: bottom top

HalfSweet commented 11 months ago

Here is the schematic for a board that I'm designing. What do you think? Are you interested on the design? PY-CAT-002

One thing worth noting is that the PY32 doesn't necessarily interact well with 3.3V level peripherals - either UARTs or SWDs - when it's running on a 5V supply, which I think is kind of a pitfall.

And, the V3 pin of the CH340 seems to require an external 0.1uF capacitor, I'm not quite sure, you'll need to check the datasheet