STM32 PlatformIO

Sweet!
We need @glyn.hudson to drop the ‘sudo’ from the repo readme to avoid further confusion.

Thanks, I can access Miniterm now as user.

Paul

2 Likes

… and now I’ve deleted them and reclaimed 0.6GB of space!!!

pi@raspberrypi:~/v5/stm32tests/emonTxshield $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       7.2G  6.1G  843M  88% /
devtmpfs        460M     0  460M   0% /dev
tmpfs           464M     0  464M   0% /dev/shm
tmpfs           464M   13M  452M   3% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           464M     0  464M   0% /sys/fs/cgroup
/dev/mmcblk0p1   42M   21M   21M  51% /boot
tmpfs            93M     0   93M   0% /run/user/1000
/dev/sda        540K  260K  280K  49% /media/pi/NODE_F303RE
pi@raspberrypi:~/v5/stm32tests/emonTxshield $ sudo rm -r /root/X.platformio
pi@raspberrypi:~/v5/stm32tests/emonTxshield $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       7.2G  5.5G  1.4G  81% /
devtmpfs        460M     0  460M   0% /dev
tmpfs           464M     0  464M   0% /dev/shm
tmpfs           464M   13M  452M   3% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           464M     0  464M   0% /sys/fs/cgroup
/dev/mmcblk0p1   42M   21M   21M  51% /boot
tmpfs            93M     0   93M   0% /run/user/1000
/dev/sda        540K  260K  280K  49% /media/pi/NODE_F303RE

now I’m thinking the 2nd set of libs must be also 0.6GB, plus the actual PIO install, I bet I could claim back a full 1.0GB (give or take) by removing PIO entirely.

If you’re logged is as a non-root user, and you do

sudo usermod -a -G $USER

it’ll make the change for that user.

1 Like

Typo, I thought I had typed $USER that why the USER was in CAPS. Edited now cheers Bill.

YWS!

I ordered a Nucleo F303RE and a shield today. Thought I’d follow the thread a bit more than just reading it.
This has been one of the more enjoyable and (especially) educational reads on the forum in quite some time.

1 Like

I wonder how many users have 2 copies of the complete toolchain and libs etc on their emonPi’s?

Mmmmh! there’s a name for people that find enjoyment in the suffering of others :grin:

sudo usermod -a -G dialout paul works just fine for dialout.
I assume Bill is talking more global.

Great news Bill, look forward to your contribution!

Paul

1 Like

Yes it’s using a environment variable so that it that work’s without editing, even with sudo eg

pi@raspberrypi:~ $ sudo echo $USER
pi

Especially morbid are those who want to partake of that suffering! :wink:

Thanks, Paul! I’m looking forward to having a play with it.

2 Likes

Great!

No Ubuntu 14.04

Sudo should not be required if dialout groups are setup correctly. It’s fine to install platformio with sudo initially. I think this is required. Sudo should not be required when running and uploading.

However I believe the Pi has an issue (least older raspbian) where sudo is required to access the tty ports (at least /tty/AMA0). This is a raspberry pi issue.

Update:

Looks like the RasPi issue has been fixed. See Pio docs:

http://docs.platformio.org/en/latest/installation.html?highlight=dialout#system-requirements


I will make a PR to remove sudo from the readme. If sudo is used with platformIO you will need to restore the permissions of /home/user/.platformio and delete the temporary project folders .piolibdeps and pioenvs

Done and merged:

I’ve also made PR to smt32oem add the gnu99 flag, although it seemed to make no difference for me. But I’ve included it to keep the Pio version as close to the make version as possible. YMMV please let me know.

2 Likes

Just for clarity, @Paul is NOT using a RPi, he is using a Debian amd64 VM and adding his user to the dialout group has improved his issue with having to use sudo and duplicated libs and toolchain etc.

I am using a RPi and the user pi already belongs to the dialout group on later Raspbian distro’s, only some early distro’s eg Wheezy did you have to add the user pi to dialout manually.

I have just checked my RPi that uploads without any problems and the “99-platformio-udev.rules” is not present and does not appear to be needed.

I do not know if the udev rules are present on Pauls set up, but he is also able to flash/upload without an issue so I’m personally not keen on diverging from the standard install method of using that one install command, because it works, I see no reason to start altering the bits that DO work.

I have looked at your gnu99 PR and it is the same as you have already suggested in post #3 of this thread, the results of trying that are shown step by step in post #6. It doesn’t work, I have posted what did work.

Do you intend setting up a Pi to try your guide?

Even after I apply the above gnu99 fix it fails to print any values, we see the value labels but there are no values.

It does and I did :slight_smile:

Hi

I have just set this up on a Pi 3.

I first had exactly the same problem as @pb66 . I altered the platformio.ini as per his post with the gnu99 on a separate line and it compiled perfectly.

build_flags =
  -Wl,-u_printf_float
  -D std=gnu99

build_flags = -std=gnu99

I had an issue uploading as I had no /media/pi/NODE_F303RE directory. I had to run the pi directly with a monitor and startx and then the board was automatically recognised and the directories created.

I also had a lot of difficulty in getting platformio installed. In the end I found this reference:-
https://www.raspberrypi.org/forums/viewtopic.php?p=1221550

I ran the script and after that platformio worked perfectly.

Regards

Ian

Another minor little quirk I’ve unearthed.

I was just playing with Miniterm to see what it’s like and to set up a alias etc and I found the pio device monitor gets it’s baud from the platformio.ini file in the current working directory, so it can only effectively read the nucleo’s serial output when you are in the project folder, unless you can pass other args to the command.

Here I have miniterm set up with the alias nucleo and I ran that and pio device monitor from the users home folder, the default working directory.

pi@raspberrypi:~ $ nucleo
--- Miniterm on /dev/ttyACM0  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
PU temp: 30C, Vdda: 3306mV
0: Vrms: 1143.09, Irms: 8.66, Papp: 9893.55, Preal: -11.38, PF: -0.001
1: Vrms: 1143.09, Irms: 87.92, Papp: 100505.85, Preal: 2598.43, PF: 0.026
2: Vrms: 1143.09, Irms: 87.93, Papp: 100509.11, Preal: 2598.43, PF: 0.026
3: Vrms: 1143.08, Irms: 87.93, Papp: 100507.77, Preal: 2459.48, PF: 0.024
CPU temp: 30C, Vdda: 3306mV

--- exit ---
pi@raspberrypi:~ $ pio device monitor
--- Miniterm on /dev/ttyACM0  9600,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
�!!At?}"�B��!�!�A�ñ§¤}����"��F��'!�A����â1!�B�~F���!"��â!�}�B�����Bï�"�!�@"�!��B���@�!Gâ�?�}g!$�B����A!
--- exit ---

pio device monitor has started with a baud of 9600 as the platformio.ini isn’t there, so it’s output is rubbish.

Hi Ian, thanks for confirming I’m not alone!

What OS distro are you using?

The auto-detection of the usb device in console mode is a fairly new thing I think, I can recall similar instances to what you describe (with other usb storage devices) but haven’t seen that behavior of late. Once upon a time if I plugged in a USB stick I had to mount it manually or open startx (via xrdp).

Plus the script you linked just installs PIP and pyserial (perhaps Python too, that’s commented out) both of which are included in the Raspbian Stretch (full version) and AFAICR always have been (in the full versions) but I cannot vouch for the lite versions, but as you have startx I sorta’ ruled that out.

[edit - can you also confirm if you have any values in your serial prints or just labels?]

Hi Paul

Print out and OS details

2: Vrms: , Irms: , Papp: , Preal: , PF:
3: Vrms: , Irms: , Papp: , Preal: , PF:
0: Vrms: , Irms: , Papp: , Preal: , PF:
1: Vrms: , Irms: , Papp: , Preal: , PF:
2: Vrms: , Irms: , Papp: , Preal: , PF:
1: Vrms: , Irms: , Papp: , Preal: , PF:
2: Vrms: , Irms: , Papp: , Preal: , PF:
3: Vrms: , Irms: , Papp: , Preal: , PF:
0: Vrms: , Irms: , Papp: , Preal: , PF:

--- exit ---
pi@webcam:~/STM32Dev/dBC_txshield_demo $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
pi@webcam:~/STM32Dev/dBC_txshield_demo $

I am just assembling a shield to test.

1 Like

Thanks again Ian, I think the PIO installation for the Pi definitely needs some work.

If this isn’t resolved soon, you can simply install the arm toolchain from the debian repos and use make, that works perfectly.

sudo apt-get update && sudo apt-get install -y gcc-arm-none-eabi

I am slowly documenting setting up a dev env on a Pi (stm32tests/README.md at master · stm32oem/stm32tests · GitHub) that guide is going to change pretty soon as minicom isn’t required, miniterm is better.

I can see it’s Stretch you have installed, but did you use the full or lite version?

Full version

Just tried make.

make
mkdir build
/usr/bin/arm-none-eabi-gcc -c -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32F303xE -IInc -IDrivers/STM32F3xx_HAL_Driver/Inc -IDrivers/STM32F3xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32F3xx/Include -IDrivers/CMSIS/Include -O2 -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/adc.d" -MT"build/adc.d" -std=gnu99 -Wa,-a,-ad,-alms=build/adc.lst Src/adc.c -o build/adc.o
In file included from Src/adc.c:41:0:
Inc/adc.h:47:27: fatal error: stm32f3xx_hal.h: No such file or directory
 #include "stm32f3xx_hal.h"
                           ^
compilation terminated.
Makefile:190: recipe for target 'build/adc.o' failed
make: *** [build/adc.o] Error 1

I assume I am using a different source file from github. Which one are you using?

How odd!

I just had a thought that perhaps I have been rebooting my Pi so much that perhaps it only detected devices on boot, so I unplugged my nucleo, rebooted and checked for the device, plugged in the nucleo and checked again. It’s definitely auto-detecting.

pi@raspberrypi:~ $ ls -la /media/pi
total 8
drwxr-x---+ 2 root root 4096 Mar 29 14:15 .
drwxr-xr-x  3 root root 4096 Mar 22 18:08 ..
pi@raspberrypi:~ $ ls -la /media/pi
total 12
drwxr-x---+ 3 root root 4096 Mar 29 14:18 .
drwxr-xr-x  3 root root 4096 Mar 22 18:08 ..
drwxr-xr-x  2 pi   pi   1024 Jan  1  1970 NODE_F303RE

When did you last run an apt-get update and dist-upgrade?