Homeβ€Ί JGAurora A5S, A1 & A3S-V2β€Ί Modifications & Upgrades

PLANNING: New firmware

24

Comments

  • Richy_TRichy_T Posts: 142🌟 Super Member 🌟
    I would think so. I have no idea how marlin does it. Interrupts?
  • FrezapFrezap Posts: 21Member, 🌟 Super Member 🌟
    What do you guys think about klipper? https://github.com/KevinOConnor/klipper

    It supports STM32F1 but I couldn't get it to boot. The screen hangs at Enter FW....

    What do we know about the bootloader, or where can I learn more about it?

    Greetings
    Frezap

  • jelot_itjelot_it Posts: 25Member, 🌟 Super Member 🌟
    edited February 2019
    I'm a newbie on marlin firmware, but today, after many readings, I've started a new branch for the JGAurora A5S A1 board (board/jgaurora_a5s_a1).

    I have compiled the firmware with the basic configurations, but after the upload it remains fixed on the progress bar and does not restart (as opposed to the original firmware).

    The idea is to be able to communicate with the new firmware before correctly compiling the configuration files,
    but I do not know if it's the right way.

    Any suggestion is welcome :)

    P.S. in Configuration.h use: #define MOTHERBOARD BOARD_JGAURORA_A5S_A1





    Post edited by jelot_it on
  • Richy_TRichy_T Posts: 142🌟 Super Member 🌟
    Are you using the software Samuel was talking about? Could the projects be transported to something free?
  • jelot_itjelot_it Posts: 25Member, 🌟 Super Member 🌟
    @Richy_T no, I used "PlatformIo IDE for Atom" following the instructions in the Marlin documentation.


    to update the STM32F1 HAL on linux it was necessary to run the following command:
    pio update

    I created the initial version of the pins_JGAURORA_A5S_A1.h looking at the Dlion/pins.h file of the original source code.

    This night I realized that dropbox shows me the original "Doc/02. Development environment description.txt" file with the correct charset, so I used the google translator and got the file that I attach.

    There is a lot of information ... I hope to deepen and make further tests soon
  • Samuel PinchesSamuel Pinches Posts: 2,997Administrator
    edited February 2019
    Spent a lot of time looking into this this weekend, lost a lot of wasted hours troubleshooting due to a dodgy ST-Link... :s waiting on a new adapter now. Ideally would be good to get a bootloader integrated to allow flashing over USB from a computer, because presumable we will lose the ability to flash via SD with a new firmware.

    Sounds like @jelot_it made some great progress! Looking forward to trying things out soon.
    Thanked by 1jelot_it
    Post edited by Samuel Pinches on
  • Samuel PinchesSamuel Pinches Posts: 2,997Administrator
    Quick update:
    • managed to get arduino code running on the A5/A1 motherboard, working serial port etc.
    • having trouble getting marlin 2.0 to load successfully
    • very likely that installation will require opening the case, at least for the initial installation
    • likely that installation will require a ST-Link - they are $4 on ebay, I recommend anyone who is remotely interested in custom firmware down the track to buy one.

    Thanked by 1jelot_it
  • Samuel PinchesSamuel Pinches Posts: 2,997Administrator
    edited February 2019
    Some more details:
    The "download" port on the motherboard contains a JTAG SWD interface, but the pinout is completely non-standard. this will help anyone who wants to flash:


    Connect this port up to an ST-Link V2 using jumper wires / dupont cables, and you will be able to backup and upgrade the firmware on the A5S & A1.

    EDIT: I had 3.3v and ground mixed up... rookie error! Diagram above corrected now.


    Thanked by 2jelot_it Frezap
    Post edited by Samuel Pinches on
  • Samuel PinchesSamuel Pinches Posts: 2,997Administrator
    Finally, the jgaurora firmware has two parts - there is a bootloader which starts up first, and then loads the main firmware. The firmware bin files that JGAurora provides are just the second part. The bootloader part remains untouched during updates. I've attached the bootloader - it just needs the firmware appended to be flashed via the ST-link, enabling you to go back to stock firmware without any worries.

    The bootloader is responsible for loading the firmware file off the SD card, and for performing the flash-in-place.

    The main firmware has a feature called "update fonts" and "update pictures" that loads other files from the SD card and flashes them to the secondary flash chip on the motherboard.

    There is also a small third EEPROM on the motherboard, which stores the serial number and model of the printer.
    Thanked by 1jelot_it
  • jelot_itjelot_it Posts: 25Member, 🌟 Super Member 🌟
    Great job @Samuel Pinches . In these two weeks I was busy and I could not work on it, but tomorrow I should be able to do more tests.

    Thanks for all the information you have shared.

  • Samuel PinchesSamuel Pinches Posts: 2,997Administrator
    edited February 2019
    Awesome :smile: - I'm going to try to figure out an accurate pinout tonight.Β  I tried to flash the MKS robin (which uses the same CPU) example provided with marlin, using Platformio, but the upload doesn't seem to boot :(
    Any progress in that area would be supurb!
    Post edited by Samuel Pinches on
  • Samuel PinchesSamuel Pinches Posts: 2,997Administrator
    edited February 2019
    Corrected a few errors.... here's v1.1

    Thanked by 2Frezap jelot_it
    Post edited by Samuel Pinches on
  • Samuel PinchesSamuel Pinches Posts: 2,997Administrator
    edited February 2019
    Oh man... I just realised you had already figured out the CPU pinout ... and posted it 12 days ago in your github. Looks like I did it the hard way... DOH! :D


    Post edited by Samuel Pinches on
  • Samuel PinchesSamuel Pinches Posts: 2,997Administrator
    Making progress.... beginning to understand Platformio :s
    I also noticed that the pins in that translated document are also incorrect, the ones in github from the pins_DLION appear to be correct.
  • jelot_itjelot_it Posts: 25Member, 🌟 Super Member 🌟
    @Samuel Pinches yes, the translated document has some errors, but I found it useful anyway.

    I also found your document created in the "hard way" very useful for double checking the one extracted from the source code.

    Probably the MKS robin firmware does not work because it is encrypted (@see Marlin/buildroot/share/PlatformIO/scripts/mks_robin.py file).

    I have updated the repository with the latest progress... ;)

    >>> M115
    SENDING:M115
    FIRMWARE_NAME:Marlin bugfix-2.0.x (Github) SOURCE_CODE_URL:https://github.com/MarlinFirmware/Marlin PROTOCOL_VERSION:1.0 MACHINE_TYPE:JGAurora A5S EXTRUDER_COUNT:1 UUID:cede2a2f-41a2-4748-9b12-c55c62f367ff
    Cap:SERIAL_XON_XOFF:0
    Cap:EEPROM:0
    Cap:VOLUMETRIC:1
    Cap:AUTOREPORT_TEMP:1
    Cap:PROGRESS:0
    Cap:PRINT_JOB:1
    Cap:AUTOLEVEL:0
    Cap:Z_PROBE:0
    Cap:LEVELING_DATA:0
    Cap:BUILD_PERCENT:0
    Cap:SOFTWARE_POWER:0
    Cap:TOGGLE_LIGHTS:0
    Cap:CASE_LIGHT_BRIGHTNESS:0
    Cap:EMERGENCY_PARSER:0
    Cap:AUTOREPORT_SD_STATUS:0
    Cap:THERMAL_PROTECTION:1
    Cap:MOTION_MODES:0
    I have also committed the configuration files for the A5s and the A1, but they are minimal configured (just to take advantage of the correct pin file).

    I can flash the firmware with these steps:
    1. - compile the board/jgaurora_a5s_a1 branch
    2. - copy the firmware.bin into the SD
    3. - with the printer turned off and not connected to the PC, insert the sd into the printer
    4. - connect the printer to the PC via USB
    5. - when the progress bar is 100%: disconnect the printer from the pc and remove the sd
    6. - open the printer and disconnect the flat cable of the LCD monitor
    7. - close the printer, connect it to the PC via USB and turn on the printer
    8. - now you can send commands via pronterface
    be careful because the configuration.h file is not configured, so the motors will move in the wrong way.

    is needed to disconnect the LCD monitor or communication with the PC will not work.

    I will try to see if I can solve the problem with the connected lcd monitor, so for now I will not modify the configuration files further ... if someone wants to do it: clone the repository and proceed :)

    and... sorry for the bad english
    Thanked by 1Samuel Pinches
  • Samuel PinchesSamuel Pinches Posts: 2,997Administrator
    edited February 2019
    @jelot_it you're doing AWESOME work Jean-louis!!


    I finally (FINALLY!!) got a working build too, but there is something wrong with the temperature reading, so it resets almost straight away... but if you connect a serial monitor you will see there is some output :-P

    I modified the python script for the MKS Robin to allow flashing of the full firmware via ST-Link:

    put jgaurora_ax.py in /Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/scripts
    put jgaurora_ax.ld in /Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/ldscripts
    put jgaurora_bootloader.bin in /Marlin-bugfix-2.0.x

    add this line to env in platformio:
    extra_scripts = buildroot/share/PlatformIO/scripts/jgaurora_ax.py

    I'm going to try downloading your build because I'm stumped by this temperature reading problem...

    Since mine doesnt seem to have any problem with the LCD, I'm going to try to see whats going on there.

    Post edited by Samuel Pinches on
  • Samuel PinchesSamuel Pinches Posts: 2,997Administrator
    two steps forward one step back




  • jelot_itjelot_it Posts: 25Member, 🌟 Super Member 🌟
    edited February 2019
    wow, you talk to the LCD monitor :)

    I pushed a new commit that solve the need to detach the LCD cable... so I could flash the printer and talk with it (without open the printer) with this steps:
    1. compile the board/jgaurora_a5s_a1 branch
    2. copy the firmware.bin into the SD
    3. with the printer turned off and not connected to the PC, insert the sd into the printer
    4. connect the printer to the PC via USB
    5. when the progress bar is 100%: disconnect the printer from the pc and remove the sd
    6. turn on the printer
    7. now you can send commands via pronterface
    be careful because the configuration.h file is not configured, so the motors will move in the wrong way.

    B)
    Thanked by 1Samuel Pinches
    Post edited by jelot_it on
  • Samuel PinchesSamuel Pinches Posts: 2,997Administrator
    edited February 2019
    These are the only changes I made so far to what you have

    in pins_JG.h:

    //
    // LCD Pins
    //
    #define FSMC_CS_PIN PD7
    #define FSMC_RS_PIN PG0

    in configuration.h:

    //
    // MKS Robin 320x240 color display
    //
    #define MKS_ROBIN_TFT

    Also noticed filament diameter set to 3mm in your conf.


    I suspect what we're seeing with the dodgy bed readings could be due to allocating the wrong ADC (1, 2 or 3) to the correct pin (PC2) - perhaps its trying to read the ADC to two pins at the same time. I'm not sure how to change that - its stumping me. I was able to create a simple Arduino sketch to confirm the pin is correct, but I had to compile it against the official ST STM32 HAL so I could use the pin name, whereas we're using the community maple based STM32 HAL for Marlin. I reckon migrating to the official HAL would be a good goal to set.
    void setup() {  Serial.begin(115200); }
    void loop() {
      int sensorValue = analogRead(PC2);
      Serial.println(sensorValue);
      delay(1);        // delay in between reads for stability
    }

    I think what I might be seeing with the dodgy LCD could be due to a mismatch in set speed somewhere?

    If you set the platform to the latest dev build STM32 (platform = https://github.com/platformio/platform-ststm32.git) I get build errors - may be good to look into that. The advantage there is the offical HAL and community HAL are separated out into two different frameworks, framework-arduinoststm32 and framework-arduinoststm32-maple respectively

    I'm running out of time so I'm going to have to leave this here for a while... :|

    Thanked by 2jelot_it aestrems
    Post edited by Samuel Pinches on
  • Samuel PinchesSamuel Pinches Posts: 2,997Administrator
    LOL you beat me to everything in the time I took to wrote my post... :D

    I'll leave you to it - main thing that is a show stopper is needing to get the bed readings working!!
  • jelot_itjelot_it Posts: 25Member, 🌟 Super Member 🌟
    LOL :)

    in the last commit I have defined the FSMC_RS_PIN as:

    #define FSMC_RS_PINΒ Β Β Β Β Β Β  PF0

    the value PF0 is the default value taken from the translated documentation and from the file ./Marlin/src/HAL/HAL_STM32F1/u8g_com_stm32duino_fsmc.cpp (alias FSMC_RS_A0)

    your PG0 comes from?

    thanks for the link, I will check it soon

  • Samuel PinchesSamuel Pinches Posts: 2,997Administrator
    edited February 2019
    I got that PG0 from mapping the RS pin (labelled on LCD PCB) to the CPU pin on the motherboard. Sounds like initialisation of the LCD is a pain because the controller can vary - but it also sounds like we can take advantage of the fact that the controller is initialised by the boot loader!
    Post edited by Samuel Pinches on
  • Samuel PinchesSamuel Pinches Posts: 2,997Administrator
    I think the problem with the bed readings may be a ADC pin configuration problem - not that we have selected the wrong pin, but that we have not correct assigned one of the three ADC's to that pin. I think the file we need to change is ~\.platformio\packages\framework-arduinoststm32\STM32F1\variants\generic_stm32f103z\board.cpp

    The question is.... I don't know what the change is that is required. :disappointed:

  • jelot_itjelot_it Posts: 25Member, 🌟 Super Member 🌟
    yesterday I made a last commit with the modified Configuration.h files (I took the data from the original code, but probably will be re-edited).

    I deliberately left the bed turned off, but be careful because not reading correctly the temperature value, the extruder immediately heats up

    the file ~\.platformio\packages\framework-arduinoststm32\STM32F1\variants\generic_stm32f103z\board.cpp seems correct to me

    I think we should act on the Marlin/Marlin/src/module/temperature.* files (maybe in the Temperature::analog_to_celsius_hotend and Temperature::analog_to_celsius_bed functions)

    in the original code we have these settings:
    #define TEMP_0_PIN     (Get_Adc(ADC_Channel_12)>>2)
    #define TEMP_BED_PIN (Get_Adc(ADC_Channel_11)>>2)

    where ADC_Channel_* are configured as:
    #define ADC_Channel_11                              ((uint8_t)0x0B)
    #define ADC_Channel_12 ((uint8_t)0x0C)

    (so, board.cpp seems correctly configured)

    Get_Adc() instead use this sample rate:
    #define ADC_SampleTime_239Cycles5                  ((uint8_t)0x07)

    maybe on marlin we do not use the same samplerate, but I think our problem may be the division by 4 made in the pin file:

    #define TEMP_0_PIN     (Get_Adc(ADC_Channel_12)>>2) // the >> 2
    #define TEMP_BED_PIN (Get_Adc(ADC_Channel_11)>>2) // the >> 2

    we probably need to have a custom conversion ... the thermistor used in the source code looks identical to what we set up on marlin (the 1 value [1 : 100k thermistor - best choice for EPCOS 100k (4.7k pullup)])

    Now I have to go to work. I'll do some tests tonight

    Thanked by 1Samuel Pinches
  • Samuel PinchesSamuel Pinches Posts: 2,997Administrator
    edited February 2019
    When I tested reading from the bed thermistor port on my own program, I had no problems. What I’m wondering is if because were using both the nozzle thermostat and the bed thermistor on ADC1 (just on different channels), whether that might be causing the problem because? I was wondering if we have to move ADC1 to ADC2 for the bed readings, and use ADC1 just for the nozzle readings.

    I thought the operator >> is a bit wise shift to the right, so it’s only divide by 2, not 4?
    Thanked by 1jelot_it
    Post edited by Samuel Pinches on
  • jelot_itjelot_it Posts: 25Member, 🌟 Super Member 🌟
    edited February 2019
    I thought the operator >> is a bit wise shift to the right, so it’s only divide by 2, not 4?

    shift to the right of N position, so it make a division for 2^N
    i.e. 16 is 00010000 in binary notation... 00010000 >> 3 = 00000010 = 2 in decimal notation, so we have divided for 2^3

    I deepened a bit the "road" of division, but in reality this is done in the Marlin/src/HAL/HAL_STM32F1/HAL.cpp file (@see HAL_adc_start_conversion function)

    I was wondering if we have to move ADC1 to ADC2 for the bed readings, and use ADC1 just for the nozzle readings.

    honestly I do not know and at the moment I have no ideas...
    today I get the stlink cable purchased, if I understand how it works I try to do some debugging.

    P.S. I have enabled the: #define SHOW_TEMP_ADC_VALUES in the Marlin/Configuration_adv.h file, but when I try to run the M105 command I do not see the raw value... I have to enable something else?

    Thanked by 1Samuel Pinches
    Post edited by jelot_it on
  • jelot_itjelot_it Posts: 25Member, 🌟 Super Member 🌟
    edited February 2019
    I made a new push to the repository with this change:
    • updated the marlin core with the last commit from upstream repository
    • fix the read of the temperature sensors B)
    the problem was an undefined pin_index on STM32F1, solved with this commit. [edit] new commit ... seems more correct and seems to work better
    I do not know if it's the correct way to solve the problem, but that file did not know our pins ... so I think it's correct

    be careful because even if the temperature is read, currently the printer does not respect the limits and continues to heat the extruder




    Post edited by jelot_it on
  • Samuel PinchesSamuel Pinches Posts: 2,997Administrator
    edited February 2019
    You're awesome @jelot_it ! I'm still stuck in kindergarden here trying to figure out how and what exactly you fixed :lol:

    Post edited by Samuel Pinches on
  • Samuel PinchesSamuel Pinches Posts: 2,997Administrator
    edited February 2019
    Ok, I think I give up. I am really stumped about this LCD. :disappointed:

    The only clue I found is, that the distortion is mostly resolved when I connect any two of the data pins e.g. connect DB5 (PE7) and DB6 (PD1) on the LCD. Very odd! See the photo below.

    I think the issue is the hold time. I can't figure how to change the ADDHOLD timing. I tried changing the FSMC_ADDRESS_SETUP_TIME and FSMC_DATA_SETUP_TIME in the STM32F1 HAL file:Β  "u8g_com_stm32duino_fsmc"



    Useful documents attached.
    Thanked by 1jelot_it
    Post edited by Samuel Pinches on
Sign In or Register to comment.