Moving code from ESP8266 to ESP32

Image
A while ago I made a mashup of Dan Royer's code CNC 2 Axis Demo with my own code for trapezoidal motion stepper and servo control for ESP8266.

I assumed porting the code to the ESP32 would be trivial, and that was true for the most part: changes like library name being Wifi.h instead of Wifi8266.h were not a problem. UDP now does not like multicharacter writes but you can use print instead. So far so good.

However, when it came to the interrupt code I was stuck with the stepper interrupt causing an exception sometimes. And to make things weirder, the servo interrupt worked flawlessly (both of them had the IRAM_ATTR directive if you ask me).

Going little by little, I could narrow down the culprit to a floating point operation during the interrupt, that would cause problems sometimes but not always. Browsing around I found this post. Where the solution was simple: do not use floats within the interrupt routines but doubles. The reason was the float calculation would be performed by…

It didn't take long before I have to use it

My kid's computer harddisk was dying last week. It booted up and it worked but sometimes after a clean shutdown CHKDSK was triggered on next boot (they use XP pro). The check was reporting some damaged sectors and I knew a replacement was due. I better do it now or I will have to reinstall everything from scratch.

I went to the shop and I've got a new 160GB Maxtor drive. But, as usual, things were not exactly smooth: Old drive was a 40GB IBM drive with a single FAT32 partition. I wanted to get a bigger partition as the new drive was larger and I wanted to copy the old winxp system onto the new drive.

Unfortunaltely, due to some defective clusters, G4U software stopped after copying only 6 GB and the result disk was unusable. G4L also failed because of the same reason. I borrow a copy of Ghost 2003 for DOS just to discover that I needed a boot floppy to run it and that my floppy drive was not working and full of dust. I got rid of the dust from the floppy and it eventually worked and so did Ghost 2003 that also allowed me to expand the destination partition.

Other solution that did work was the rescue mode of G4L that is also able to copy a partition with (some) defective clusters. What it did not work for me was "parted" software afterwards to expand the 40 GB partition onto a bigger one.

In the mean time I decided to install Ubuntu Linux on the same system, but unfortunately I was not aware that my motherboard BIOS was only capable to handle 137GB of my harddrive, and I managed to install Ubuntu in the last 4GB of my 160GB drive, so I could not boot it. Even worse, I accepted the recomended setting of using GRUB boot manager on my disk MBR, so afterwards I just got an Error 17 instead of a boot menu, so I could not boot either WinXP or Ubuntu Linux.

This latter incident was fixed by FIXMBR command from winxp install CD-ROM rescue mode and later on Ubuntu was moved to a new home within the harddisk below the 137GB limit.

Now everything works again but most of my weekend had gone trying the different approaches until succeeding. I did not mention all the attempts just to keep things short (I even was told to say a little prayer).

Comments

Popular posts from this blog

VFD control with Arduino using RS485 link

4xiDraw: Another pen plotter

Software I2C for Arduino