MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
15.97k stars 19.09k forks source link

Get Re-ARM stuff for LPC1768 over to 32-Bit-RCBugFix-new #7121

Closed Roxy-3D closed 6 years ago

Roxy-3D commented 6 years ago

This is all from @p3p 's work.

We don't want to forget about the LPC1768 stuff in 32-Bit-RCBugFix-new !

When the file & folder reorganization happens, it is important this stuff is included!

p3p commented 6 years ago

@Roxy-3D This isn't necessary my LPC1768 branch is already based on my new.. new 32bit HAL branch (#7028) that @thinkyhead will merge before the reorganisation, don't worry about it being forgotten about I've been the one keeping the HAL up to date, the platforms and HAL are in separate branches to keep rebasing easy until the big refactoring. The platforms are self contained in their individual folders so have no effect on any other part of marlin and can be seamlessly merged at any time.

(The LPC1768 branch is very experimental so wasn't included in the main PR)

Roxy-3D commented 6 years ago

OK! Good to know!!!! (You can tell I really want the Re-ARM stuff ready to go!)

p3p commented 6 years ago

I'm trying ^^ I've only had the board about 2 weeks (getting it to the UK was expensive), for the last few days I've been working on removing mbed as a dependency and researching getting the usb working so I've unfortunately gone backwards a bit in functionality, temporary setback though.

Roxy-3D commented 6 years ago

Yeah... I would like to see us able to update the firmware via USB instead of messing with the SD-Card! I also think we should fill out those undefined pins in the pinmap_re_arm.h file so that any pin on the RAMPS board is accessible using its ATMega-2560 pin number. The documentation at https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/1047536701/original/Re-ARM%20pinouts.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJ2JSYZ7O3I4JO6DA%2F20170622%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20170622T232858Z&X-Amz-Expires=300&X-Amz-Signature=a1c9aae70a9d98e2c283c0159064ecee51d106a1791f944f3f76eaf82b00f1c7&X-Amz-SignedHeaders=Host&response-content-type=application%2Fpdf tells us what those missing port and pin numbers need to be. It is just a matter of updating the list you have to get rid of the {0xff,0xff} entries.

Roxy-3D commented 6 years ago

Incidentally.... I'm able to get code loaded and running on the Re-ARM board. But right now... It is just using your digitalWrite() function to blink LED's using the RAMPS pins.h file numbers. The LCD Panel still doesn't work... But now I'm ready to go figure that out.

p3p commented 6 years ago

yea the pinmapping is a work in progress I was just filling it in and adding the Defines as I needed them, I'm glad you've managed to get something working, it would be nice to know if Marlin is managing to boot all the way and your LCD is just not working (timing issue? ST7920_DELAY in HAL.h) or if its an issue during setup. (I've been working off that pdf, not all pins have a mapping though)

Roxy-3D commented 6 years ago

Well... a lot of stuff is working... I now have my LED blinking in the loop() function. And I had too long of a delay() specified and I watched the board shut down because of the watch dog timer... I'm kind of blind about what it is going on. But for sure, a lot of stuff is working. I'll try messing with the ST7920_DELAY tomorrow.

Roxy-3D commented 6 years ago

@p3p I still have LCD Panel problems... First I tripled the ST7920_DELAY's in HAL.h Still no splash screen.

But I do know the firmware is able to do some stuff with the LCD Panel. I added some code to check if the Encoder Wheel is pressed and if so, stop incrementing the LED's and instead chirp at the user. That does work... So at least the button side of the LCD Panel is there and working. And for that matter... The speaker works on the LCD Panel too.

void loop() {
static int i, j, k;
  pinMode( 3, OUTPUT);  // X-Min
  pinMode( 2, OUTPUT);  // X-Max
  pinMode( 14, OUTPUT); // Y-Min

      if (ubl_lcd_clicked() )
        chirp_at_user();
      else
        i++;

      digitalWrite( 3,  i & 0x01 );
      digitalWrite( 2,  i & 0x02 );
      digitalWrite( 14, i & 0x04 );
      delay(500);
Roxy-3D commented 6 years ago

@p3p Hey!!! My LCD is working. I was powering my board from a USB plug, and apparently, the 5 volts isn't passed through to the various 5 volt pins. It gets cut down enough in an attempt to regulate it that the LCD Panel didn't display anything. For now, I just jumpered the 5 volts past the regulator so I can still use the USB plug for power. But probably when I actually am using it on a printer it can get 12 volts from the RAMPS board.

bobc commented 6 years ago

@p3p Have you looked at https://github.com/ExploreEmbedded/Explore-M3 ? It's a fairly complete Arduino API for LPC1768, I've did some hacking to it to get USB working. I was working on LPCXpresso 1768 board, so should be similar.

Roxy-3D commented 6 years ago

Very cool! No, I didn't know about that. But a couple of things jump out... First, we can probably support the Re-ARM board on Arduino. That makes it easier for people that are moving from AVR boards to a Re-ARM. Probably... If we are careful with the code, we can compile (and load) on either PlatformIO or Arudino.

But the cool thing is with an extra switch, we can load the board from Arduino instead of messing with SD Memory cards. An official and working 32-Bit version of Marlin is getting closer and closer!!!

bobc commented 6 years ago

Explore-M3 is a package for Arduino, that was why I mentioned it.

p3p commented 6 years ago

@Roxy-3D I was really trying to think of something different between our hardware setups and that didn't even occur to me, (mine is powered from the hardware serial), I'm glad its working everything makes sense again.

@bobc That's good to know, using an Arduino implementation like that is definitely an option, I was intending to implement it at CMSIS level as far as possible but that was only by preference and to try and give a "generic" ARM template.

Roxy-3D commented 6 years ago

@p3p When you say "Hardware Serial" do you mean the UART connector close to where the LCD Panels split ribbon cable plugs in to get 5 volts? I need some kind of serial interface so I can see the SERIAL_ECHO() information.

What are you using to interface? (Can you provide an eBay link so I can order the right thing?) And where are you plugged into the board?

p3p commented 6 years ago

The 6 pin connector that comes out horizontally from the board, it's a standard FTDI compatible connector, (5V, GND, and UART), I mentioned this to you a few times when trying to help with the LCD, I probably wasn't very clear. https://www.sparkfun.com/products/9717 would be one option, the LPC1768 is 5V tolerant on most pins so you don't specifically need the 3.3V version (it still supplies 5V VCC).

Roxy-3D commented 6 years ago

Yes... You did mention it. And I started looking up FTDI and got overwhelmed. There were a lot of things I didn't understand. Like RS-232 is supposed to be +/- 12 volts but this was +5 volts and Ground. But all that aside... So I started using LED's to see if I could get any code loaded on the board. And to see if I could tell what was happening.

Do you display the output of that USB cable inside of PlatformIO ? I see a PlatformIO-ide-terminal package that I can install.

p3p commented 6 years ago

There is a button (second to bottom) on the left that looks like a plug, it opens a serial port terminal after choosing port and baudrate, you don't need to install anything else.

Roxy-3D commented 6 years ago

Hah!!!!! THANKS!!!! Cable is on its way.

Roxy-3D commented 6 years ago

@Bob-the-Kuhn I know I used to have your email address. And I used to have your shipping address. But I can't find either right now. Can you email me your shipping address and then I'll have both in one place? Thanks!!!

p3p commented 6 years ago

one of the first things I'll do is put in code that uses a file on the SD-Memory card for EEPROM simulation

@Roxy-3D Actually, that's already working, along with the USB stack (much tidying and reorganising required), although I've somehow managed to go backwards with the graphical display(fixed). The work continues although there are parts I need to change in the HAL API (such as the persistent store API I added and hooked into Marlin settings, the already defined macros made that simple), with the big merge pending I don't want to do that too much though.

oh if you test this don't access the SD card over USB at the same time as writing the eeprom, I still need to implement the auto disconnect on local filesystem mount, also its probably worth saying don't have anything on the SD card you care about (disclaimers ect ect)

Bob-the-Kuhn commented 6 years ago

Bob Kuhn 1034 Wisteria Trail Austin, TX 78753 bob.kuhn@att.net

thinkyhead commented 6 years ago

@Bob-the-Kuhn I see that you are only a 10 minute drive from where I live, on Dessau Rd. We should get together sometime to get the HAL and 2.0 branch hammered out. I've got all the ducks in a row, but it would be good to be able to bounce ideas around. I also have several boards to test on, including RAMPS, Due, and Re:Arm, plus one or two extra RAMPS shields. And, Saturday is "Software Saturday" at the local maker-space, just a mile from here.

Bob-the-Kuhn commented 6 years ago

Bouncing ideas off me?!!? That's funny. I appreciate the compliment.

I'm hoping to be helpful but I expect it'll probably in the area of helping keep the 8 bit stuff off your back. Don't be afraid to assign things to me.

The wife's making threatening remarks about putting some drywall up in the bathroom and shopping for tile.

I'm sure I can drop into the maker-space sometime Saturday but I have no idea when. Give me a shout at (+++) +++-++++ & I'll see if can meet you there.

Now to find out what a maker-space is.

Bob-the-Kuhn commented 6 years ago

@Roxy-3D - can you provide a brief startup sequence for getting the P3P on my Re-ARM with RAMPS1.4?

p3p commented 6 years ago

@Bob-the-Kuhn It should be relatively painless

  1. Swap out controller
  2. Install PlatformIO IDE
  3. Clone https://github.com/p3p/Marlin.git and Checkout 32bit-bugfix-1.1.x-LPC1768
  4. Open the PlatformIO project from the PlatformIO Home screen (Browse to the folder containing platformio.ini and click OK, it kinda odd you don't select anything)
  5. Click PlatformIO->Run other target.. (or press F7), Scroll to the bottom of the list to build for Re-ARM
  6. Copy Marlin/.pioenvs/Re-ARM/firmware.bin to sdcard and put into Re-ARM then reset.
  7. Marlin boots flawlessly and everything works. (End user experience may vary)

This branch is under active development I usually only push to github when its working but no guarantees, I'm currently in the middle of reorganising and pondering if its possible to hide folders from the Arduino IDE (I have never really used it), wrapping entire frameworks in ifdefs is not really feasible.

Apart from the horrible mess the main omission from the current build is character displays, otherwise it should support baseline Ramps 1.4 features.

Roxy-3D commented 6 years ago

can you provide a brief startup sequence for getting the P3P on my Re-ARM with RAMPS1.4?

Once you grab p3p's latest branch at: https://github.com/p3p/Marlin/tree/32bit-bugfix-1.1.x-LPC1768 the biggest (most complicated) is to get PlatformIO installed. It is some add-in that runs inside of the Atom text editor.

You can start the install process here: http://platformio.org/get-started/ide?install=atom

I forget... But there is some add-in or package that you have to install and restart Atom a couple times to get it to stick. And it is a little bit less than intuitive to get P3P's branch loaded into it as a project. But once that happens... You should have a screen that looks like this:

image

You then need to go to the very lower left corner and select PIO-Build-ReARM out of the list. And with that selected you can go to the far middle right 'build' button. It looks like a lightning bolt.

At the end of a successful build you should get something that looks like:

Calculating size .pioenvs\Re-ARM\firmware.elf text data bss dec hex filename 137900 2444 5040 145384 237e8 .pioenvs\Re-ARM\firmware.elf Building .pioenvs\Re-ARM\firmware.bin [SUCCESS] Took 329.44 seconds

Hunt down the firmware.bin file. Put it on a FAT-32 formatted SD-Memory card. (I believe it needs to a 4GB or bigger card but I could be wrong on that.) And power up or reset the Re-ARM board. If the firmware got updated on the board, the .bin file will be gone and it gets renamed to firmware.cur

At that point... You should see the Marlin logo and splash screen if you have a Graphics LCD Panel plugged into the RAMPS board and have the magic 5 volt ribbon cable plugged in the right place.

p3p commented 6 years ago

But there is some add-in or package that you have to install and restart Atom a couple times to get it to stick

@Roxy-3D that's interesting there shouldn't be any extras needed, will have to reinstall from scratch to make sure I'm not forgetting something, Have you had any luck with the new USB serial and Mass storage btw, I havn't had time to test it on windows yet (OK I keep forgetting).

Roxy-3D commented 6 years ago

that's interesting there shouldn't be any extras needed,

I don't remember... But I was following a Help Page describing the steps. And there was some version problem or something. It might have even been the PlatformIO-IDE add in that had the version problem. I don't remember. But there was some package it was telling me to install and you had to do some funny things to get it to stick. And the help file did warn about that.

I have not tried the USB Serial or Mass storage yet. Do you mean 'Persistent Storage' ? And when you say 'USB Serial', does that mean PronterFace can receive SERIAL_ECHO() messages now over the USB Cable?

p3p commented 6 years ago

The Re-ARM is now detected as a Mass Storage device (like a usb stick) so you can access the onboard sdcard, and on linux at least it is just detected as a Serial device and shows up like an any other usb serial device (on windows you may need to install the driver file from the LPC1768 folder, but have yet to test it), its still a work in progess (like everything else) The persistent storage is different that's just what I called the saving eeprom data to the onboard sdcard.

Roxy-3D commented 6 years ago

OK! Understood! This is what I mean by 'Making Progress Fast'. All of these little things help speed up development and shaking out the bugs from the firmware. Having 'Critical Mass' is important (at least to me) and we are going to have it!!!!

PS. I just got my FTDI Serial cable today. But I ordered a Squid cable and I got one with a flat, inline connector. I guess grudgingly... My soldering and shrink tubing skills are going to get tested again. But only if I can't get the USB Serial to work! :)

p3p commented 6 years ago

tbh the code isn't in a state that I would usually feel comfortable making it public, it's mostly at the make the features work and see how everything will fit together stage.

Roxy-3D commented 6 years ago

tbh the code isn't in a state that I would usually feel comfortable making it public, it's was mostly at the make the features work and see how everything will fit together stage.

Yes! Everybody understands that! There won't be any complaints.

I am impressed with how much progress you have made and how easy it is to 'follow' and catch up.... That is what we want. We want a whole group using the same tool chain and code base you are using. And like I say... Somebody here is going to see value and enjoy doing things like removing the Yellow compile time warnings. Several other people are going to be focused on the Delta's. It is going to be a real treat to see Delta's not have any CPU saturation issues.

You are making it so a whole team can join in on the effort.

Bob-the-Kuhn commented 6 years ago

I'm not getting a "PIO-Build-ReARM" option when I click "PIO Build" in the lower left.

I see the python script "lpc1768_flag_script.py". Do I need to do something with it? It looks like it may solve the compile errors I'm getting.

p3p commented 6 years ago

That happens when you don't open the project properly, the script is called automatically by PlatformIO during the build, when you open the project you have to browse the folder containing platformio.ini and make sure no folders are selected, then click open. When you click pio-build there should be a long list of options including due, teensy and re-arm (at the bottom).

Roxy-3D commented 6 years ago

When you click pio-build there should be a long list of options including due, teensy and re-arm (at the bottom).

And when you click it... You get a list of stuff. But there is stuff off the bottom of the list you can't see until you force it to scroll up....

Roxy-3D commented 6 years ago

@p3p

The Re-ARM is now detected as a Mass Storage device (like a usb stick) so you can access the onboard sdcard,

Yes... It appears I can update the firmware.bin file directly from the USB now. No more moving SD Memory cards around! :)

and on linux at least it is just detected as a Serial device and shows up like an any other usb serial device (on windows you may need to install the driver file from the LPC1768 folder, but have yet to test it), its still a work in progess (like everything else)

So far... I have not gotten the Serial port to work. Can you tell me the driver's name so I can hunt it down? When I plugged in the USB cable this is what I got

usb

But I went ahead and tried to use PlatformIO's Serial Monitor (the little power plug on the lower left side). I set the baud rate at 115,000. But no luck. I only had 1 COM: port to choose from. Probably the COM1: port wasn't the Re-ARM board.

p3p commented 6 years ago

The driver file is "HAL_LPC1768/usb/lpc17xx-vcom.inf", you should be able to install it through device manager, Windows used to ask you if it should look automatically or you could specify the driver directly when you plugged it in?

Roxy-3D commented 6 years ago

@Bob-the-Kuhn Bob, how are you doing getting the Re-ARM loaded with firmware? I'm having trouble getting the serial port driver to load. Its almost like the composite device doesn't have a serial port in it.

p3p commented 6 years ago

Same problem here on Windows 10 so I'l have to figure something out

Roxy-3D commented 6 years ago

@p3p do you know if the USB serial device the Re-ARM board is trying to present to the host computer is physically using the serial port that is brought out to the connector pins under the RAMPS Aux-2 connector? Can I just connect up an FTDI cable and use that?

And if so... On the FTDI cable can I just ignore the CTS and RTS wires? I don't think those signals are brought out to the connector. The connector is Gnd Gnd +5V Rx Tx

p3p commented 6 years ago

Currently the USB Serial is the only port that can send data to the Re-ARM, the hardware serial can only mirror the output (I was using it to debug),

CTS should be connected to ground, RTS can be ignored (it shows NC on the Re-ARM pinout), I'l try and get the USB Serial working on windows tonight. What version of windows are you on?

Bob-the-Kuhn commented 6 years ago

I haven't made any progress.

Maybe these screen shots will help trouble shoot the issue. I'm running Win10.

In the mean time I'll try a fresh install on a different machine.

image

image

Roxy-3D commented 6 years ago

CTS should be connected to ground, RTS can be ignored (it shows NC on the Re-ARM pinout),

Ok. That will be easy to wire up if it comes to that.

I'l try and get the USB Serial working on windows tonight. What version of windows are you on?

Window-7 primarily. But if Windows-10 is easier to get going... I can move to a Windows-10 laptop.

Roxy-3D commented 6 years ago

Bob... You don't want to do 'PIO Build' You want to scroll down (you can't see it until you scroll down). You want to select 'PIO-Build-(Re-ARM)'

p3p commented 6 years ago

Window-7 primarily. But if Windows-10 is easier to get going... I can move to a Windows-10 laptop.

@Roxy-3D huh I would have expected the driver in the LPC1768/usb folder to work on Windows 7

@Bob-the-Kuhn That platformio.ini file shouldnt exist? its in the directory above

Roxy-3D commented 6 years ago

huh I would have expected the driver in the LPC1768/usb folder to work on Windows 7

I see the lpc17xx-vcom.inf file. But I don't see anything executable. Does something special have to happen to get the device driver file built? The lpc17xx-vcom.inf references things like usbser.sys and that is no where to be found. I'm starting to think the USB serial device driver did not get built????

p3p commented 6 years ago

There is no driver binary, the inf file just instructs windows what built in driver to use. if you go into device manager and find the unrecognised device you can tell windows to use that inf file,

PS. on windows 10 I can force it to use the generic usb serial driver and it works fine, its just a matter of getting windows to realise that's the driver to use.

Roxy-3D commented 6 years ago

I've got 2 unknown devices. Neither of them lets me load that lpc17xx-vcom.inf file. But here is why I'm confused. Shouldn't the device show up as a USB device? I don't have any unrecognized USB devices.

p3p commented 6 years ago

I think I may need to have a more OS's installed, I'm not sure how windows 7 lays out the device manager, its under Other devices for me.

p3p commented 6 years ago

@Roxy-3D Ok, apparently Windows needs told specifically when 2 interfaces descriptors are for the same device, but that's fixed now Windows 10 picks up the serial device no drivers needed, I need to install a VM to test on windows 7 but this may have made the driver work.. I can hope.