libmaple makefiles

Post your cool example code here.
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: libmaple makefiles

Post by ag123 »

try CMake with 'official' core too
viewtopic.php?t=1648
https://github.com/stm32duino/CMake_workspace

I think cmake is 'better'. really. cmake helps to modularize code blocks, setup using cmakelist.txt files.
i managed to make very small binaries omitting whole modules e.g. usb etc. Useful if compact binaries is needed.
rpav
Posts: 11
Joined: Sat Apr 29, 2023 2:37 pm

Re: libmaple makefiles

Post by rpav »

Can someone explain why this simple blink code will not work.
It seem like it compiles and flashes OK; but no activity on STM32F103C8 broad.
It work in the Arduino environment.

CODE:
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin PB1 as an output.
pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

OUTPUT:
Terrestrial Control System v.009|| STATE: maintenance
Response: ASSEMBLE
copy from `build/blue_pill.elf' [elf32-littlearm] to `build/blue_pill.bin' [binary]

text data bss dec hex filename
12264 2152 968 15384 3c18 build/blue_pill.elf

-rwxrwxr-x 1 craft craft 14416 May 28 20:33 build/blue_pill.bin


build/blue_pill.elf: file format elf32-littlearm

Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00002c58 08000000 08000000 00010000 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .text.align 00000000 08002c58 08002c58 00023850 2**0
CONTENTS, ALLOC, LOAD, CODE
2 .ARM.exidx 00000008 08002c58 08002c58 00012c58 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .data 00000868 20000000 08002c60 00020000 2**3
CONTENTS, ALLOC, LOAD, DATA
4 .rodata 00000388 080034c8 080034c8 000234c8 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .bss 000003c8 20000868 20000868 00030868 2**2
ALLOC
6 .debug_aranges 00000f40 00000000 00000000 00023850 2**3
CONTENTS, READONLY, DEBUGGING, OCTETS
7 .debug_info 00005272 00000000 00000000 00024790 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
8 .debug_abbrev 000020a2 00000000 00000000 00029a02 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
9 .debug_line 00006981 00000000 00000000 0002baa4 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
10 .debug_frame 00002414 00000000 00000000 00032428 2**2
CONTENTS, READONLY, DEBUGGING, OCTETS
11 .debug_str 0000325e 00000000 00000000 0003483c 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
12 .ARM.attributes 00000029 00000000 00000000 00037a9a 2**0
CONTENTS, READONLY
13 .debug_ranges 00001998 00000000 00000000 00037ac3 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
14 .comment 00000049 00000000 00000000 0003945b 2**0
CONTENTS, READONLY

Source dirs
src
./STM32F1/cores/maple
./STM32F1/variants/blue_pill

src/
./STM32F1/cores/maple/
./STM32F1/cores/maple/avr/
./STM32F1/cores/maple/libmaple/
./STM32F1/cores/maple/libmaple/stm32f1/performance/
./STM32F1/cores/maple/libmaple/usb/stm32f1/
./STM32F1/cores/maple/libmaple/usb/usb_lib/
./STM32F1/cores/maple/stm32f1/
./STM32F1/variants/blue_pill/
./STM32F1/variants/blue_pill/wirish/

Includes
-ISTM32F1/cores/maple/
-ISTM32F1/system/libmaple/
-ISTM32F1/system/libmaple/include/
-ISTM32F1/system/libmaple/stm32f1/include/series/
-ISTM32F1/system/libmaple/usb/stm32f1/
-ISTM32F1/system/libmaple/usb/usb_lib/
-ISTM32F1/variants/blue_pill/

Defines
-DMCU_STM32F103C8
-D__STM32F1__
-DVECT_TAB_ADDR=0x8002000
-DUSER_ADDR_ROM=0x08000000
-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG
-DDEBUG_LEVEL=DEBUG_NONE
-DF_CPU=72000000L
-DSERIAL_USB
-DUSB_VID=0403
-DUSB_PID=6001
-DUSB_MANUFACTURER="Unknown"
-DUSB_PRODUCT=
-DLED_BUILTIN=PC13
-DHAVE_ERROR_LED
-DERROR_LED_PORT=GPIOC
-DERROR_LED_PIN=13
craft@vmc:~/Arduino_STM32-master$ tools/linux64/serial_upload ttyUSB0 2 0403:6001 build/blue_pill.bin
stm32flash Arduino_STM32_0.9

http://github.com/rogerclarkmelbourne/arduino_stm32

Using Parser : Raw BINARY
Interface serial_posix: 115200 8E1
Version : 0x22
Option 1 : 0x00
Option 2 : 0x00
Device ID : 0x0410 (Medium-density)
- RAM : 20KiB (512b reserved by bootloader)
- Flash : 128KiB (sector size: 4x1024)
- Option RAM : 16b
- System RAM : 2KiB
Write to memory
Erasing memory
Wrote address 0x08003850 (100.00%) Done.

Starting execution at address 0x08000000... done.
rpav
Posts: 11
Joined: Sat Apr 29, 2023 2:37 pm

Re: libmaple makefiles

Post by rpav »

Correction code:
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin PB1 as an output.
pinMode(PC13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(PC13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(PC13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

It seem like it compiles and flashes OK; but no activity on STM32F103C8 broad.
It work in the Arduino environment.
rpav
Posts: 11
Joined: Sat Apr 29, 2023 2:37 pm

Re: libmaple makefiles

Post by rpav »

Problem solved!
Changed -DVECT_TAB_ADDR=0x8002000 to -DVECT_TAB_ADDR=0x8000000
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: libmaple makefiles

Post by ag123 »

hope you liked that make file, I created that out of the frustration that in eclipse (without specific Arduino plugins) it is difficult to transfer configurations to new projects/sketches.

With this, creating a new project simply means copying the whole directory at the root with the makefile into a new folder and making updates.
And it did away with the Arduino IDE

This is also 'fluid', in the sense that all the flags are in the makefile, tune them to your liking.
:)
rpav
Posts: 11
Joined: Sat Apr 29, 2023 2:37 pm

Re: libmaple makefiles

Post by rpav »

Looks good. I am pretty new to programming. So I do not know of many of the flags that are to be use, but I am learning. I am trying to figure why the serial interfaces are not working (Serial.begin(115200)). I guest I will eventually figure it out.
rpav
Posts: 11
Joined: Sat Apr 29, 2023 2:37 pm

Re: libmaple makefiles

Post by rpav »

I usually put a new folder in the root/package directory and have the new directory makefile point to root directory Make.rules file.
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: libmaple makefiles

Post by ag123 »

The default Serial() in libmaple is USB Serial, i.e. you should be able to see a 'virtual com port' in Windows, or in Linux a /dev/ttyACMx device.
if you run dmesg it should also show some messages when your device is connected.

In linux additionally, make a file /etc/udev/rules.d/45-maple.rules
the entries looked like such

Code: Select all

ATTRS{idProduct}=="1001", ATTRS{idVendor}=="0110", MODE="664", GROUP="plugdev"
ATTRS{idProduct}=="1002", ATTRS{idVendor}=="0110", MODE="664", GROUP="plugdev"
ATTRS{idProduct}=="0003", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="plugdev" SYMLINK+="stm32duino" ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idProduct}=="0004", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="plugdev" SYMLINK+="stm32duino" ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idProduct}=="5740", ATTRS{idVendor}=="0483", MODE="664", GROUP="plugdev" SYMLINK+="stm32duino" ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idProduct}=="0004", ATTRS{idVendor}=="0483", MODE="664", GROUP="plugdev" SYMLINK+="stm32duino" ENV{ID_MM_DEVICE_IGNORE}="1"
and restart (udev, e.g. , systemctl restart systemd-udevd.service) when you plug a device with libmaple or STM 'official' core, you would see the device /dev/stm32duino when it is plugged in.
that ID_MM_DEVICE_IGNORE is to tell modemmanager to ignore this device, otherwise it keeps trying to probe and initialize it as a modem.

for windows there may be some 'drivers' setup/config to be done:
https://github.com/rogerclarkmelbourne/ ... stallation
rpav
Posts: 11
Joined: Sat Apr 29, 2023 2:37 pm

Re: libmaple makefiles

Post by rpav »

For some reason it shows up as "/dev/ttyUSB0", but I can not connect to it.
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: libmaple makefiles

Post by ag123 »

what does dmesg output look like?
oh and patch that /etc/udev/rules.d/45-maple.rules as given 2 comments earlier
without that the modemmanager tends to lock it up as it tries to initialize it as a modem.
Post Reply

Return to “Code snippets”