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

MSG:Warning: Settings write failed! #121

Closed
nickshl opened this issue May 26, 2023 · 16 comments
Closed

MSG:Warning: Settings write failed! #121

nickshl opened this issue May 26, 2023 · 16 comments

Comments

@nickshl
Copy link
Contributor

nickshl commented May 26, 2023

I made controller using WeAct Studio BlackPill F411. I build firmware using web builder with defaults except I enabled Spindle Sync. When I tried to enter command in console I got an error:

$14=64
ok
[MSG:Warning: Settings write failed!]

Build info:

$I
[VER:1.1f.20230519:]
[OPT:VNMSL,35,1024,3,0]
[AXS:3:XYZ]
[NEWOPT:ENUMS,RT+,ES,TC,SS,SED]
[FIRMWARE:grblHAL]
[NVS STORAGE:*FLASH]
[DRIVER:STM32F411]
[DRIVER VERSION:230513]
[BOARD:BlackPill]
[AUX IO:1,2,0,0]
ok

NVS STORAGE:*FLASH - should be right... wait, let's try Nucleo-64 F401, it used to work. And it works. Build info:

$I
[VER:1.1f.20230519:]
[OPT:VNMSL,35,1024,3,0]
[AXS:3:XYZ]
[NEWOPT:ENUMS,RT+,ES,TC,SS,SED,RTC]
[FIRMWARE:grblHAL]
[NVS STORAGE:*FLASH]
[DRIVER:STM32F401CC]
[DRIVER VERSION:230513]
[BOARD:Nucleo-64 CNC Breakout]
[AUX IO:4,7,0,0]
ok
@nickshl
Copy link
Contributor Author

nickshl commented May 26, 2023

Additional info: after I sent $14=64 and got error, I opened ioSender and set all other settings. After that all settings was saved and preserved via power cycle. When I tried to change $14 via PuTTY I got error again.

@hanke-cnc
Copy link

This issue only occurs on the F401 series chips and not on the F446. I have reported this issue to terjeio, but it seems that terjeio does not have an F401 circuit board, so they have not fixed it and only send error messages when writing fails. Unfortunately, I am not a programmer. The specific manifestation of this problem is that when the chip is powered on for the first time, if you only set one parameter, that parameter will not be saved after power-off. You must set another parameter, such as 384=1 or something, for the parameter to be saved.

@terjeio
Copy link
Contributor

terjeio commented May 27, 2023

The first write (or rather erase) fails after power up if the MCU is programmed with the STM32 ST-Link Utility, when I program with STM32CudeIDE it does not - I have no idea why.

Retrying the erase if it fails seems to fix the issue, I will commit an update later today with this workaround.

For new board designs I strongly recommend adding at the minimum a footprint for an I2C EEPROM, even better to add one as well - best is FRAM. 2Kb minimum, 4Kb+ recommended as new features may require more capacity. This since there is no wear levelling implemented when storing to flash.

terjeio added a commit that referenced this issue May 27, 2023
NOTE: not yet used by any board map files.
Workaround for issue #121, settings write failure.
Improved frequency range for spindle PWM.
@nickshl
Copy link
Contributor Author

nickshl commented May 27, 2023

Since there no wear leveling, I prefer to have control of writing. Setting change command can be volatile and change value only in RAM, and another command can be issued to save settings($SAVE probably?)

@terjeio
Copy link
Contributor

terjeio commented May 27, 2023

another command can be issued to save settings($SAVE probably?)

No, this will require users to be aware of and remember issuing the $SAVE command. This is a breaking change I am not willing to implement.
And most changest to the storage area is not when changing settings but rather when changing offsets, e.g. when setting or zeroing the current position.

Changes are buffered in RAM and written to permanent storage when the controller is in IDLE or ALARM mode and not in file run mode.
If sending more than one settings in one go put the controller in file run mode while sending the settings. This is done by encapsulating the command block in % characters e.g:

%
$0=5
$1=49
%

It might be possible to create a plugin that intercepts writeouts and implements a $SAVE command, this since the calls are indirected via function pointers.

@nickshl
Copy link
Contributor Author

nickshl commented May 27, 2023

or zeroing the current position

Wait, what? Every time when I press "zero" button in sender, grblHAL write it into NVM? It is unacceptable behavior in case flash used for store settings!

No, this will require users to be aware of and remember

User doesn't need to remember anything. User uses sender. Sender have to do it. Like change all desired settings, then press "Write" button... wait, that exactly what I have to do if I want save settings using ioSender, isn't it? Beside, it needed only if flash used to store settings. EEPROM and FRAM can save settings immideatly.

@terjeio
Copy link
Contributor

terjeio commented May 27, 2023

Wait, what? Every time when I press "zero" button in sender, grblHAL write it into NVM? It is unacceptable behavior in case flash used for store settings!

That is why I recommend using EEPROM or FRAM. AFAIK most flash tolerate in the region of 10000 - 100000 erase/write cycles before wearing out so it isn't a likely problem for hobby grade use...

User doesn't need to remember anything. User uses sender. Sender have to do it.

Ok, I may consider adding it when all relevant senders has the $SAVE command implemented for flash storage that does not have wear levelling support. You can write up the spec and distribute to sender developers and come back to me with an estimate for when they are ready for this?

@nickshl
Copy link
Contributor Author

nickshl commented May 28, 2023

You can write up the spec and distribute to sender developers

Just gave me a list of senders specifically made for grblHAL and know about all additional settings and I will consider to do that 🙂

If you don't want to break anythyng by introducing any new functionality, it may be configurable with additional $ parameter and have existing behavior by default.

@nickshl
Copy link
Contributor Author

nickshl commented May 29, 2023

For new board designs I strongly recommend adding at the minimum a footprint for an I2C EEPROM, even better to add one as well - best is FRAM.

Decided to give it a try, ordered MB85RC256V module, then found 24C256 module in electronic component pile, opened blackpill_map.h... and realized that there no I2C definitions. Web builder does not have EEPROM option available for this board either.

@terjeio
Copy link
Contributor

terjeio commented May 30, 2023

Have you made a board already or are you wiring directly to a Blackpill?
Motor 3 pins GPIOA 6 and 7 could be swapped with feed hold/cycle start pins on GPIOB 6 and 7 to free up pins for I2C in a new board map.

@nickshl
Copy link
Contributor Author

nickshl commented May 30, 2023

I didn't make PCB and I am not sure if I will. For now I use prototyping PCB to make a lathe controller. But my goal to make simple instruction how to recreate it, so it have to be implemented in Web Builder.

At this point I ended with this pinout:

/* Default Pin Assignments:
 *
 *                         -----------
 *                     VB |           | +3V
 *       Step En/Dis  C13 |           | GND
 *     Coolant Flood  C14 |           | +5V
 *      Coolant Mist  C15 | *     - * | B9   I2C SDA
 *                    RST |      |K|  | B8   I2C SCL
 *             Reset   A0 |       -   | B7   Feed Hold
 *       Door Safety   A1 |           | B6   Cycle Start
 *            X Step   A2 |           | B5   Probe
 *       X Direction   A3 |    / \    | B4   Encoder Index
 *            Y Step   A4 |   <MCU>   | B3   Encoder Pulse (B)
 *       Y Direction   A5 |    \ /    | A15  Encoder Pulse (A)
 *            Z Step   A6 |           | A12  USB D+
 *       Z Direction   A7 |   -   -   | A11  USB D-
 *            A Step   B0 |  |R| |B|  | A10  USART1_RX
 *       A Direction   B1 |   -   -   | A9   USART1_TX
 *    Spindle Enable   B2 |           | A8   Spindle PWM
 * Spindle Direction  B10 |           | B15  A Limit
 *                    +3V |   -----   | B14  Z Limit
 *                    GND |  |     |  | B13  Y Limit
 *                    +5V |  | USB |  | B12  X Limit
 *                         -----------
 */
  • Y2 Step, Dir & Limit removed since lathe uses only X & Z axis. Y axis still there just in case someone will try to upgrade lathe to a mill by adding third axis on cross slide.
  • Step En/Dis moved to PC13 since this pin has LED on Black Pill
  • X, Y, Z and A Step/Dir shifted, Reset and Door Safety moved to PA0 & PA1. PA0 connected to a button on BlackPill.
  • Probe moved to B5, A Limit placed to B15 - group with other limits.
  • Cycle Start moved to PB6.
  • PB9 & PB8 used for I2C.
  • Encoder Index moved to PB4, this pin can be used as TIM3 input.
  • PB3 left for encoder phase B input since TIM2 can use PA15 & PB3 as encoder input.
  • PA10 & PA9 left for UART1 for MPG stream input which I hope will be supported in future.
  • All available pins used or planned to be used.

Is there any issues with such layout? If no, could you add attached blackpill_lathe_map.h to repo and Web Builder?

blackpill_lathe_map.h.txt

Full disclosure: I didn't tried it. There may be some issues with GPIO_MAP or GPIO_SHIFT, may be those have to be replaced with GPIO_BITBANG.

Update: Probe moved to B5, A Limit moved to B15 - group with other limits. Yes, I am perfectionist.

terjeio added a commit that referenced this issue Jun 2, 2023
@terjeio
Copy link
Contributor

terjeio commented Jun 2, 2023

I have added the map as Blackpill Alt. 2 with a number of additional options:

  • Aux I/O depending on available pins.
  • I2C Keypad option, again depending on available pins.
  • EEPROM defaults to 2K in the Web Builder - disable or select as needed.
  • Spindle sync option is not forced.
  • ...

Note that I have not tested with the map.

If you plan to add a website for your build then a link can be added to the board Homepage button in the Web Builder .

@terjeio terjeio closed this as completed Aug 26, 2023
@nickshl
Copy link
Contributor Author

nickshl commented Nov 17, 2023

Hi @terjeio, I have a request about Blackpill Alt. 2 configuration: is it possible to add the 5th axis? I missed two pins when I did this confuguration: PA13 and PA14. Those pins are used for debug/programming via SWO, however they can be used as GPIO. I would like to use PA13(SWDIO) as B Step and PA14(SWCLK) as B Dir.

I am a trace PCB for the CNC controller and want to order boards this weekend. It is almost(there always a place for improvement 🙂) perfect, but last minute I realize that it would be nice to have the 5th axis... and there are two unused pins suitable for that.

@terjeio
Copy link
Contributor

terjeio commented Nov 18, 2023

is it possible to add the 5th axis?

Yes, that is possible as it will be a non-breaking change.

@nickshl
Copy link
Contributor Author

nickshl commented Dec 7, 2023

Hi @terjeio, I finally close to release my version of CNC breakout board(actually controller, since BlackPill will be included).
And because of that I would like to change some things... if possible.

  1. I would like to change name of the board(and name of file too) from "BlackPill Alt. 2 (STM32F411)" to "Devtronic breakout board (BlackPill F411)"
  2. Since this board have dedicated door input, probably make sense to make "Safety door input" enabled by default in Web Builder
  3. This board have MB85RC256 FRAM and I would like to have appropriate setting by default in Web Builder(EEPROM is FRAM and appropriate size)
  4. Since this board have encoder input I would like to have "Spindle sync" enabled by default, if it doesn't hurt anything if not used of course.

Yes, that is possible as it will be a non-breaking change.

  1. Since this board have 5th axis connector I would like to include 5 as an option for "Number of axes:". Also I would like to modify Pin assignment section in .h file to reflect that:
/* Pin Assignments:                  
 *
 *                    B Direction -   - B Step
 *                                 | |
 *                               G S D +
 *                               N C I 3
 *                               D K O V
 *                             -----------
 *                         VB |           | +3V
 *           Step En/Dis  C13 |           | GND
 *         Coolant Flood  C14 |           | +5V
 *          Coolant Mist  C15 | *     - * | B9   I2C SDA
 *                        RST |      |K|  | B8   I2C SCL
 *                 Reset   A0 |       -   | B7   Feed Hold
 * Safety door/I2C strobe  A1 |           | B6   Cycle Start
 *                X Step   A2 |           | B5   Probe
 *           X Direction   A3 |    / \    | B4   Encoder Index
 *                Y Step   A4 |   <MCU>   | B3   Encoder Pulse (B)
 *           Y Direction   A5 |    \ /    | A15  Encoder Pulse (A)
 *                Z Step   A6 |           | A12  USB D+
 *           Z Direction   A7 |   -   -   | A11  USB D-
 *                A Step   B0 |  |R| |B|  | A10  USART1_RX
 *           A Direction   B1 |   -   -   | A9   USART1_TX
 *        Spindle Enable   B2 |           | A8   Spindle PWM
 *     Spindle Direction  B10 |           | B15  A Limit
 *                        +3V |   -----   | B14  Z Limit
 *                        GND |  |     |  | B13  Y Limit
 *                        +5V |  | USB |  | B12  X Limit
 *                             -----------
 */

Please let me know if you have any questions or concerns. Thank you!

@terjeio
Copy link
Contributor

terjeio commented Dec 8, 2023

And because of that I would like to change some things... if possible.

The listed changes cannot be added to the current map file without breaking backwards compatability, so you will have to add a new one.

  1. Making the safety door input default in the Web Builder is currently not possible. However you may force it by undefining/defining SAFETY_DOOR_ENABLE 1 in the map file.

  2. Either force FRAM in the map file or set it as default in the entry for the board in driver.json.

  3. Again, force it the map file by undefining/defining SPINDLE_SYNC_ENABLE 1.

  4. Add it to the new map file.

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

3 participants