H32 only - does not work on G32 or N32 my effort Klipper on HC32
- Success! test print works! pre-merge release: https://github.com/SteveGotthardt/klipper/releases
- my work has been accepted and merged into main klipper repo: https://github.com/Klipper3d/klipper/tree/master/src/hc32f460
- https://www.hdsc.com.cn/Category83-1490
- https://download.csdn.net/download/u012121390/15923997?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-download-2%7Edefault%7ECTRLIST%7Edefault-1.essearch_pc_relevant&depth_1-utm_source=distribute.pc_relevant_t0.none-task-download-2%7Edefault%7ECTRLIST%7Edefault-1.essearch_pc_relevant
- https://www.hdsc.com.cn/cn/Index/downloadFile/modelid/66/id/57/key/9
- Jyers/Marlin#814 - 4.2.2
The system interrupts on the HC32 are the same as CM4. But the peripheral interrupts are mapped to interrupts with a register write instead of being assiged to a specific vector number. Example for USART: There is no: USART1_IRQn in HC32 - instead choose a vector and program it
void IrqRegistration(en_int_src_t irqSrc, IRQn_Type irqType)
{
stc_intc_sel_field_t *stcIntSel = (stc_intc_sel_field_t *)
((uint32_t)(&M4_INTC->SEL0) + (4u * irqType));
// what is the source of the selected interrupt? (USART, etc...)
stcIntSel->INTSEL = irqSrc;
// set priority and enable
NVIC_SetPriority(irqType, IRQ_PRIORITY_DEFAULT);
NVIC_ClearPendingIRQ(irqType);
NVIC_EnableIRQ(irqType);
}
Called by:
IrqRegistration(INT_USART1_RI, Int000_IRQn);
The INT_USART_RI and Int000_IRQn are found in hc32f460.h Int000_IRQn is picked by the programmer, it could be 000-031 Note for Klipper: use DECL_ARMCM_IRQ(IRQ000_Handler, Int000_IRQn); That will allocate a vector in the table
- in a directory named firmware
- from a file named firmware.bin (other names work too)
- the file is then deleted from the SD card directory
- The firmware is loaded into flash at 0XC000 the vector table relocated by VTOR to 0xC000 The firmware needs to be linked with FLASH_START = 0xC000
- The loader code sets up the ICG area so no ICG area is needed for firmware build
- The loader sets up flash and ram wait states
- Clock handoff:
- CMU_XTALCFGR(8) @ 0x40054410 0xA0 (0b1010_0000) = SUPDRV, !XTALMS (osc mode), XTALDRV(Small Drive 8-16MHz)
- CMU_PLLCFGR(32) @ 0x40054100 0x11102900 => MPLLN[8:0] b16-b8 = 0x029 (0b000101001), use xtal, divide by 1 before
- So it looks like clock is 8 / 1 * 42 / 2? 168MHz
- CMU_CKSWR(8) @ 0x40054026 = 0x05 = Select MPLL as system clock
- needs an ICG area (provided by loader)
- Cortex M4 ARM core ID: 0x2BA01477
- interrupts for peripherals are not hard vector numbers
- There is 32K 'fast' SRAMH below the typical 0x20000000 at 0x1FFF_8000 ~ 0x1FFF_FFFF
- PWC_RAMPC0.RAMPDC3
- IO is slow and needs wait states if running at 200MHz
- USART uses 5 separate interrupts unlike STM32
- Atmel SAM-ICE finds core and works. https://www.segger.com/downloads/jlink/
- arm-none-eabi-
- PA09 - set as TX - connected to LED and pin 2 of CH340
- PA15 - set to RX - connected to pin 3 of CH340
- PC0 and PC1 can be used for direct serial connection (see LCD connector)
- Fan PA0 TIMA_2 PWM 1
- Head PA1 TIMA_2 PWM 2
- Bed PA2 TIMA_2 PWM 3
- Pin 1: connected to PA4
- Pin 2: GND
- Pin 3: 3.3V
- Pin 1: 5V
- Pin 2: GND
- Pin 3: PB15 - 'A'
- Pin 4: PB12 - 'B'
- Pin 5: PB13 - 'Beep'
- Pin 6: PB14 - 'Enter'
- Pin 7: PC1 - for TX/RX
- Pin 8: PC0 - for TX/RX
- Pin 9: PB2 - NC?
- Pin 10: PC6 - NC?
- Pin 1: GND - square pad
- Pin 2: 5V
- Pin 3: PB0
- Pin 4: GND
- Pin 5: PB1
The only RPi flavor I have left is a B+. I was able to get MainsailOS to work on the B+ but the system is burdened. So, I also have a Rock64 https://wiki.pine64.org/index.php?title=ROCK64 running https://www.armbian.com/rock64/ The rock64 won't boot with the RPi mainsailOS image so I tried manual install. It goes ok but when trying to get the webpage up I get 403 - forbidden. This is because nginx can't stat the mainsail directory. I installed as user 'pi' hoping it would work but I had to add www-data to group 'pi' and then restart nginx
sudo usermod -a -G pi www-data
nginx -s reload
I use octoprint on all (4) of my printers. Two have Raspberry Pi 3 and the other two are rock64. Adding the octoklipper module is easy. Adding Klipper is a little more involved. To run klipper, the host must be running: Octoprint+octoklipper module and Klippy from the Klipper repository.
There are many vids and articles on getting Klipper going from the Klipper repository. Use the Klipper H32 release (https://github.com/SteveGotthardt/klipper/releases) to prorgram the printer mainboard via SD card (not built from klipper since it's not there yet). And since the H32 config is not yet merged there are different steps to take:
-
connect to the host (RPi, rock64, etc) via SSH (windows or Linux, mac)
-
clone (using git) the Klipper repository: git clone https://github.com/Klipper3d/klipper.git
-
initialize the environment for klippy to run: klipper/scripts/install-octopi.sh or install-debian.sh or appropriate
-
open the octoprint page (octoklipper already installed) and then open the config editor
-
copy the config contents from: https://github.com/SteveGotthardt/klipper/blob/hc32f460_work/config - look for the Voxelab entries for the C2 and O1 (original Aquila)
its a bad news :(