Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 3.6? #14

Open
chrysophylax opened this issue May 20, 2021 · 16 comments
Open

Update to 3.6? #14

chrysophylax opened this issue May 20, 2021 · 16 comments

Comments

@chrysophylax
Copy link

Hi!

I'd be willing to test out updated versions of ulisp for stm32f10xxx and give feedback if that's what's needed to get it on feature parity basis. I started doing some merges based on ulisp/ulisp-arm up to 3.6 but I'm editing a bit in the blind.

(PS. I've also finally finished writing a tiny C library that exposes saving/erasing arbitrary flash pages, the new version of saveimage that uses FlashWrite32 should work perfectly with it - so if you want >1023 bytes, it's doable! I'd just like to write some unit tests first before releasing.)

It basically does an opinionated reimplementation of the ST32 Arduino core's flash handling but exposes a slightly more flexible API regarding which 1K page you want to write to (and what size that page has - the new bluepills from WeAct have 2K pages and up to 3072K flash).

For saving, ideally, you start at page 127 and if the imagesize>1K, fill the pages in reverse (127 -> 126 -> 125 -> 124) to avoid conflicting with the Arduino code.

	bool            flash_buffer_fill(const uint8_t page);
	bool            flash_buffer_flush(const uint8_t page);
  const uint32_t*       flash_buffer_handle();
  const uint32_t        flash_buffer_size();
	uint32_t        flash_read_word(const uint8_t pos);
	bool            flash_write_word(const uint8_t pos, const uint32_t value);

If it's possible to up the base ulisp to 3.6, I'll commit to writing the FlashWrite32 ifdefs and the page handling logic.

Related to #12

@technoblogy
Copy link
Owner

Thanks for the reminder. I'll update the STM32 version of uLisp to Version 3.6 over the next few days and get you a copy to test, and we can then talk about flash writing.

@technoblogy
Copy link
Owner

Is it possible to give me a list of the boards you think the new STM32 version of uLisp should support?

Also, how do you program the STM32F103 boards? The Maple Mini had a bootloader which allowed programming via USB, but if I remember correctly this was only supported by Roger Clark's core, which is now obsolete. With the Blue Pill I used an external FTDI USB-to-serial board.

@technoblogy
Copy link
Owner

Also, do you think we could support the Black Pill:

https://www.adafruit.com/product/4877

I recently bought one, so could test this too.

@chrysophylax
Copy link
Author

chrysophylax commented May 20, 2021

I've been using an ST-Link v2 that uses the debug interface to flash. Very handy little unit. :-) I use it to also view the flash contents while running. One of these https://www.bitsbox.co.uk/index.php?main_page=product_info&products_id=3282

As for the support, I think we should aim for supporting both older STM32F10xxx bluepill (which are roughly maple mini clones) and the blackpill which runs STM32F40xxx. AFAICT the upgraded Bluepills by WeAct have larger memory but retain the exact pins as before. I don't know which other stm32-based boards are popular. The colorpills are affordable and nice to keep a bunch in a drawer.

I ordered a blackpill myself but have yet to receive it. The major difference is I think the loss of one 12-bit ADC pin and some pin reordering. On the upside, it comes with a built-in USB-C bootloader which I'm eager to try (see https://www.aliexpress.com/item/1005001456186625.html).

Edit: STM32F4xxxx use a slightly different memory model so I'd have to do some changes to the API. Might be easier once I get my unit.

@technoblogy
Copy link
Owner

I've been using an ST-Link v2 that uses the debug interface to flash. Very handy little unit. :-) I use it to also view the flash contents while running. One of these https://www.bitsbox.co.uk/index.php?main_page=product_info&products_id=3282

I think I struggled with one of those without success because I'm on Mac and I think the ST-Link support software is PC only. I've also got a Black Magic Probe that I used successfully with Adafruit's STM32F405 Express:

https://www.adafruit.com/product/4382

However it would be nice to find a lower cost alternative.

@technoblogy
Copy link
Owner

Here's a bit of documentation of my flash-writer routines I used in the ARM version of uLisp:

http://www.technoblogy.com/show?3LMV

If you can emulate these on the STM32 it will be easy to support save-image and load-image.

@chrysophylax
Copy link
Author

chrysophylax commented May 20, 2021

I am on Linux and it works well with STM32CubeProgrammer https://www.st.com/en/development-tools/stm32cubeprog.html. I did not have to install any special drivers since it comes with all the binaries you need.

There is a Mac version available too. Arduino can then flash easily using the option "STM32CubeProgrammer (SWD)"

EDIT: This is using the boards available on https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json

EDIT2: There is an updated board index at https://github.com/stm32duino/BoardManagerFiles/raw/master/package_stmicroelectronics_index.json with newer gcc+stmtools. I guess I'll have to try with this later tonight.

@technoblogy
Copy link
Owner

There is a Mac version available too.

Yes - but I couldn't get that to work.

@chrysophylax
Copy link
Author

Ah, sorry to hear.

Thanks for the flash-writing routine link! That is very helpful.

@technoblogy
Copy link
Owner

I've got a Version 3.6 that compiles for the Blue Pill F103CB on the latest STM32 core. I've managed to upload it to a Blue Pill using a Black Magic Probe, and it works OK for simple programs, but I can't test it with larger examples because if I try and send a long program over serial, the serial transfer locks up. I'm a bit stuck now, and not sure what to try next.

Would you like to try it out and see if you can spot what the problem is?

Thanks,
David

@chrysophylax
Copy link
Author

Sure! Is there a branch I can check out?

@technoblogy
Copy link
Owner

technoblogy commented May 21, 2021

Here's the test program that demonstrates the serial problem that makes uLisp unusable.

void setup() {
  Serial.begin(9600);
}

void loop (void) {
  if (Serial.available()) Serial.print((char)Serial.read());
}

If you copy and then repeatedly paste this 192-character string into the Arduino IDE Serial Monitor input field and press Return it gets echoed fine:

$0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
$0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
$0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

However if you add one character to make it 193 characters, it hangs up after a few characters.

I'm on Mac, Arduino IDE Version 1.8.13, using a Blue Pill with the new STM32 core, connected to the Arduino IDE via the USB port, settings as follows:

Screen Shot 2021-05-21 at 09 48 48

Questions:

  • Can someone reproduce this on Mac?
  • Does the same thing happen on Windows and Linux?
  • Any suggestions of how to solve it?

@chrysophylax
Copy link
Author

chrysophylax commented May 21, 2021

Hi, I tried to replicate but could not. I am using the same settings as you except for the fact that my Upload method and my Port are different (Using STM32CubeProgrammer(SWD) and Linux device naming /dev/ttyACM0).

I'm on Linux, Arduino 1.8.15, Blue Pill with the latest STM32 core and I am connected using the USB port.
Screenshot from 2021-05-21 12-11-08
Screenshot from 2021-05-21 12-11-58

@technoblogy
Copy link
Owner

Thanks. So probably specific to Mac.

@chrysophylax
Copy link
Author

I found an old thread that mentioned that ST had issues with their drivers on their small ST-Link v2 debuggers for MacOSX but that a firmware upgrade should fix it. Possibly it can be of some help to get your old ST-Linkv2 debug chips running? https://www.st.com/en/development-tools/stsw-link007.html#documentation

@chrysophylax
Copy link
Author

chrysophylax commented May 22, 2021

I have created a bug report over at stm32duino/Arduino_Core_STM32#1399 tracking the serial issue.

In the meantime, a release of 3.6 with a note that the most recent supported version of the arduino core is 1.9.0 because of an upstream bug, might work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants