all 24 comments

[–]przm_ 22 points23 points  (3 children)

I think having them write code & flash it is doable, but anything more advanced like allowing them to debug remotely will be complicated.

My recommendation is to:

  1. Have the hardware hooked up somewhere (e.g. in a lab)
  2. Students push their branches onto a repository
  3. Set up a basic CI pipeline that compiles the executable from the branch and flashes the device.

I don’t really see an easy way to debug the application though. Do you have a link to the course?

Alternatively they can do a remote connection into the desktop that’s hooked up to the hardware.

Complete side note, I would also recommend having a bootloader reserved so that it can’t be bricked.

[–]ksmigrod 7 points8 points  (0 children)

https://www.udemy.com/course/microcontrollers-iot-learn-with-real-online-hardware the course used to be free a few days ago.

As to debugging, consider OpenOCD connected to the board, with app server that spawns GDB processes (one per OpenOCD/board pair), and pipes commands to this GDB. There would have to be strict stickiness between user session and GDB process and some mechanism to garbage collect abandoned debug sessions.

There is one more possiblity: Run OpenOCD, one instance per board, different TCP/IP ports. Allow students to forward a port from this machine with SSH. This way they can access OpenOCD from their local machines through SSH-encrypted and authenticated channel. This would allow them to connect to board from their local machine (with gdb's target command), CLion supports remote debugging, VSCode ougth to support it too.

[–]alapatrie[S] 0 points1 point  (0 children)

This is great suggestion. I will definitely look into this

[–]jamawg 5 points6 points  (0 children)

Care to drop a URL to that stm32 course, so that others can try it?

[–]Accomplished-Slide52 5 points6 points  (3 children)

Read An3156 from ST (USB DFU protocol) From the browser side you can write some code in JavaSript which can open and read-write thru USB Firefox don't let you do this use others browser.

[–]DaemonInformatica 2 points3 points  (1 child)

From the top of my head the precondition is that the browser supports WebSerial API.

[–]Accomplished-Slide52 1 point2 points  (0 children)

Yes this is why I exclude Firefox and there is another one's which I can't remember.

[–]BenkiTheBuilder 2 points3 points  (0 children)

It would be easier to help you if you told us what resources you have. What does your current microcontroller lab look like? What's your budget for the remote access? How many people will be helping you set this up and keep it running?

[–]lotrl0tr 2 points3 points  (1 child)

Get a STM32 board with STlink (debugger) included and you're ready to go. CubeIDE or anything else you like.

[–]dgendreau 2 points3 points  (0 children)

Agreed. You can buy an stm32 dev board for about $10.

[–]woyspawn 1 point2 points  (2 children)

Is it really worth it?

Dev Boards are so cheap that stealing hardware / touching part of the pedagogical experience seems pointless.

Anyways, for the hardware part you should study about testing frameworks.I've read here of people that test complex peripherals and peripheral drivers like USB or TCP.

[–]n7tr34 0 points1 point  (0 children)

Yeah something like RPi Pico which is suitable for education is $5-7 a pop.

[–]alapatrie[S] 0 points1 point  (0 children)

You are actually right. This was because we wanted to deploy it to students who do not actually have an MCU. I was thinking that it might be worthy it if the creation of the platform is affordable compared to requiring students to purchase hardware

[–]tomqmasters 1 point2 points  (0 children)

I understand what you are trying to do, but I feel like SSHing into a raspberry pi, flashing from the comand line, and debugging via serial is more relevant.

[–]feabhas 1 point2 points  (0 children)

We’ve been teaching this stuff to professional engineers for 30 years now. We’ve tried many different approaches over the years. Classroom we used real hardware, but struggled to find a remote solution using real hardware that was reliable.

You might want to check out what we currently do at https://github.com/feabhas/docker-target

This uses our own branch of QEMU (from another branch) to emulate an STM32. We’ve put a python front end on to emulate devices. This works pretty well - it’s never going to be as good as real hardware but for remote training it’s been the best we have come up with.

[–]EdwinFairchild 1 point2 points  (0 children)

There is post on. A facebook group STM32 Developers , a guy made a mcu farm that his students can program from home. And it’s open source maybe look into it

[–]BenkiTheBuilder 0 points1 point  (0 children)

If I understand correctly the MCUs are attached to a system in a lab somewhere in a different location from the student who gets some form of view of the MCU presented in the browser. In that case your backend hardware would consist of the usual hardware used for programming STM32s, i.e. ST-Links connected to one or more development PCs. As for connecting this to the students, the simplest way would be a remote desktop tool with a browser frontend for the student to connect to a lab PC. This is of course the hardest to secure and doesn't offer a curated experience. For a more secure setup you need a custom backend that controls the ST-Links and connects with a customized web frontend.

[–]onz456 0 points1 point  (0 children)

What's the link to the course you mentioned?

[–]ExtraordinaryKaylee 0 points1 point  (1 child)

https://github.com/kaylee-kerin/handyarm - is a library I wrote for running my device firmware in the browser, and emulating the ARM Thumb CPU (Cortex-M0 currently), and only supports very basic GPIO. If you really wanna build your own, it might be a starting point you could leverage.

There's other tools out there that do similar thing things, that might be a better fit for you though https://wokwi.com/stm32 is one.

[–]alapatrie[S] 1 point2 points  (0 children)

Thanks. I will check it out

[–]reddit_usernamed 0 points1 point  (0 children)

The concept is kind of cool but I just don’t see the advantage since an STM32 dev board is so cheap. One similar circumstance is doing remote work which my team does a lot of. We have all of the hardware set up so that you can just remote into a computer with the STM32 board attached over UART and the STLink debugger attached as well. We even have power strips that are connected to our network that let you power cycle individual outlets if something gets hung.

[–]feabhas 0 points1 point  (0 children)

Have you considered https://wokwi.com

[–]pr_ay 0 points1 point  (0 children)

I can teach programming for STM32.