Author Topic: Lightweight Scripting Language for MCUs  (Read 14389 times)

0 Members and 1 Guest are viewing this topic.

Offline gnuarm

  • Super Contributor
  • ***
  • Posts: 1352
  • Country: pr
Re: Lightweight Scripting Language for MCUs
« Reply #50 on: March 23, 2021, 05:24:26 pm »
Bootloader? You mean it wasn't already in the core memory when power was reapplied?

No, the Space Sciences department across the street had a prototype doppler weather radar that regularly corrupted the core memory.

Those durn pesky EMC requirements!!!
Rick C.  --  Puerto Rico is not a country... It's part of the USA
  - Get 1,000 miles of free Supercharging
  - Tesla referral code - https://ts.la/richard11209
 

Offline techman-001

  • Frequent Contributor
  • **
  • !
  • Posts: 748
  • Country: au
  • Electronics technician for the last 50 years
    • Mecrisp Stellaris Unofficial UserDoc
Re: Lightweight Scripting Language for MCUs
« Reply #51 on: March 23, 2021, 08:59:41 pm »
What is important to say is the user only writes
Code: [Select]
RCC_CR.
RCC_PLLCFGR.
RCC_CFGR.

as the command in the terminal.. :)

Sure, that's one way to do it but I rarely type in anything at the terminal. I might type in "rcc." to get a instant upload of the registers as they are *right now* but I do almost everything in my editor.

Many people here think that one types on some old serial terminal and waits for Forth to reply via a slow UART like C users do with printf debugging.

The reality is that Forth often leads with new things that other systems don't have. Some very smart Forth people are always experimenting with new concepts and pushing the boundaries.

For instance my 'terminal' has no USART component because it works over SWD with full flow control, via USB. It's so fast that I can dump the (pretty printed, formatted) contents of registers as seen in my previous post to my screen in a few microseconds.

You can have the same thing with C if you buy an expensive Segger, but all I need is a STM32 Disco or Nucleo board for the SWD/USB dongle.

I type the Forth source code I want run (in the target MCU) in my editor and when I hit the 'make' button in the editor toolbar, the source is uploaded to the mcu faster than I can see on the SWD terminal screen. Because it's too fast to see we have had to add a terminal beep for warnings and an automatic upload abort for errors.

We want it even faster and are working on a SPI terminal atm plus a bunch of other exciting development aids, such as using an external 16MB SPI flash to store Forth development aids for use with smaller Cortex-M0 devices with only 64KB flash.

These aids might be the entire SVD2FORTH peripheral register pretty print Words, the entire Bitfield Words, ascii pictures of pinouts etc. If we wanted to leave the $2.50 SPI memory chip with the device, we could include schematics and diagnostic flowcharts for the tech servicing it a decade later.

We have already adapted to the new paradigm of MCU's with no internal flash such as the RP2040 where we now store multiple dictionaries in the external QSPI flash.  Mecrisp-Pico Forth was released on 23 Feb 2021, only a month after the RP2040 Pico itself was released for sale. This included the time it took to actually buy Pico devices for development.

In this 'golden age of embedded' where MCU's have never been cheaper, faster, or more featureful, Forth is flourishing.
 

Offline alexanderbrevig

  • Frequent Contributor
  • **
  • Posts: 674
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
Re: Lightweight Scripting Language for MCUs
« Reply #52 on: March 24, 2021, 06:36:51 am »
In case it is interesting to some of you, I've made my own small interpreted language that I use from time to time to have a flexible in system debugging and exploration.

It is a work in progress thing, for my personal use. But PRs are welcome if you find this interesting  :-+

https://github.com/AlexanderBrevig/yalex
https://github.com/AlexanderBrevig/yalexide <- the editor/playground for prototyping scripts for larger projects.

There's an example that works on the Arduino Uno (as a proof of concept for small 8bitters) but I tend to use it on larger projects on larger  μCUs (ARM and PIC32 in my case).
 
The following users thanked this post: imo

Offline imo

  • Super Contributor
  • ***
  • Posts: 3172
  • Country: sm
Re: Lightweight Scripting Language for MCUs
« Reply #53 on: March 24, 2021, 07:07:12 am »
In order to write a celestial navigation app all you would need is a mechanical teletype worst case.. Would be better if you got a PC which can do copy/paste and work with .txt files, however  :-DD

What do you have against paper tape?  ..
Linux and teletype.. https://hackaday.com/tag/teletype/
 

Offline techman-001

  • Frequent Contributor
  • **
  • !
  • Posts: 748
  • Country: au
  • Electronics technician for the last 50 years
    • Mecrisp Stellaris Unofficial UserDoc
Re: Lightweight Scripting Language for MCUs
« Reply #54 on: March 24, 2021, 07:17:20 am »
In order to write a celestial navigation app all you would need is a mechanical teletype worst case.. Would be better if you got a PC which can do copy/paste and work with .txt files, however  :-DD

What do you have against paper tape? 

Other than the High Speed Paper Tape reader sometimes shooting (a box full of) paper tape across the room like a massive streamer, and having to clean it up, check for tears in the tape etc ?
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 9825
  • Country: fr
Re: Lightweight Scripting Language for MCUs
« Reply #55 on: March 24, 2021, 04:53:26 pm »
In case it is interesting to some of you, I've made my own small interpreted language that I use from time to time to have a flexible in system debugging and exploration.

It is a work in progress thing, for my personal use. But PRs are welcome if you find this interesting  :-+

https://github.com/AlexanderBrevig/yalex
https://github.com/AlexanderBrevig/yalexide <- the editor/playground for prototyping scripts for larger projects.

There's an example that works on the Arduino Uno (as a proof of concept for small 8bitters) but I tend to use it on larger projects on larger  μCUs (ARM and PIC32 in my case).

At first sight, it kind of looks like a cross between Lisp and Forth.
 
The following users thanked this post: alexanderbrevig

Offline abyrvalg

  • Frequent Contributor
  • **
  • Posts: 670
  • Country: es
Re: Lightweight Scripting Language for MCUs
« Reply #56 on: March 25, 2021, 11:28:46 am »
Recently I've done something similar to OP's question (scripted/interactive fiddling with STM32 peripherals) without running any MCU code at all, accessing memory-mapped registers over SWD instead.
A simple Python wrapper over pylink (Segger J-Link Python lib) halts the CPU at start and provides low level functions like read32(addr). Higher level classes with reg name properties provide things like stm.GPIOE.BSRR = val. All that with a comfort of a full PC Python (IDE, highlighting, autocomplete etc. At the end I even wrote a simple hw tester GUI polling & displaying ADC values as bars and toggling GPIOs with buttons).
Actually, this approach could be combined with some init code running on the MCU (i.e. use HAL to do complex init, then enter an endless loop and let the PC side continue the job).
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf