Site Tools


projects:3dprinting:flashforge_creator_3_pro_fan_fix:dropbear

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
projects:3dprinting:flashforge_creator_3_pro_fan_fix:dropbear [2024/10/23 17:37] adminprojects:3dprinting:flashforge_creator_3_pro_fan_fix:dropbear [2025/04/11 15:47] (current) – [Create a USB stick] admin
Line 1: Line 1:
-====== Flashforge creator pro - dropbear ssh ======+====== Flashforge Creator Pro - dropbear ssh ======
  
 |  [[projects:3dprinting:flashforge_creator_3_pro_fan_fix | <- back to Flashforge Creator 3 pro overview page]]  | |  [[projects:3dprinting:flashforge_creator_3_pro_fan_fix | <- back to Flashforge Creator 3 pro overview page]]  |
  
-This page will describe how to install dropbear on the printer.+This page will show a method how to install and get ssh access using dropbear.
  
 +==== Prerequisites ====
 +The steps below require the following dependencies. Install them first:
  
-Buildroot options: +  sudo apt-get install git build-essential libncurses-dev
-  * BR2_SHARED_STATIC_LIBS=y+
  
-For dropbear we need a statically linked file. See [[https://github.com/maximeh/buildroot/blob/master/package/dropbear/dropbear.mk|here]] for more details how to setup accordingly. 
  
-Also see [[https://buildroot.org/downloads/manual/manual.html#adding-board-support|Chapter 17Adding support for a particular board]] in the buildroot documentationThere it explains how to create a template for a new board.+==== buildroot + dropbear ==== 
 +The dropbear binary can be easily built using [[https://buildroot.org/|buildroot]]. For this, we clone the [[https://github.com/linux4sam/buildroot-at91.git|buildroot-at91]] repository because the AT91 architecture is close to the Allwinner V3s ARM Cortex A7 CPU. After git clone, cd into the repository. 
 + 
 +  git clone https://github.com/linux4sam/buildroot-at91.git 
 +  cd buildroot-at91 
 + 
 +Since we do not have the same build environment as flashforge had, we will create a static build of dropbear. This requires to modify the dropbear package file in buildroot: 
 + 
 +  sed -i "s/disable-static/enable-static/g" package/dropbear/dropbear.mk 
 + 
 +Then we need to configure buildroot for the right processor architecture and target software. Either download the configuration to build dropbear or configure manually, as shown further below: 
 + 
 +  mv .config .config_ORIG 
 +  wget -O .config https://www.auditeon.com/xyz/flashforge_dropbear_br2023.10.config 
 + 
 +=== Configure buildroot manually === 
 + 
 +  make menuconfig 
 + 
 +Then set the following options accordingly: 
 + 
 +<code> 
 +Target options: 
 +  Target Architecture (Arm (little endian)) 
 +  Target Architecture Variant (cortex-A7) 
 +  Target ABI (EABI) 
 +  Floating point strategy (VFPv4) 
 +  ARM instruction set (ARM) 
 +  Target Binary Format (ELF) 
 + 
 +Toolchain: 
 +  C library (glibc) 
 +  Kernel Headers (Linux 6.1.x kernel headers) 
 +  *** Glibc Options *** -> Enable compatibility shims to run on older kernels (enable this option) 
 + 
 +Build options: 
 +  strip target binaries (Enable this option) 
 +  libraries (both static and shared)  <-- this will set BR2_SHARED_STATIC_LIBS=y 
 +                                          for dropbear, together with patching 
 +                                          packages/dropbear/dropbear.mk 
 +Target packages: 
 +  Networking applications ---> 
 +    * dropbear  (enable this option) 
 +      * client programs  (enable this option) 
 +      * optimize for size  (enable this option) 
 +</code> 
 + 
 +Go back to the main screen (click twice on exit) and click on Save 
 + 
 + 
 +==== Start building cross compiler and dropbear ==== 
 + 
 +  make 
 + 
 +This step may take about 20 minutes (core i7-1370P x 20). When done, verify if dropbear is correctly built: 
 + 
 +  file output/target/usr/sbin/dropbear 
 + 
 +We should see the following: 
 + 
 +  dropbear: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), statically linked, for GNU/Linux 3.2.0, stripped  
 + 
 + 
 +===== Create USB stick ===== 
 +To get SSH on the printer, we need to put some files on a USB stick, mimicking as if the printer would do a firmware update. Insert an empty FAT formatted USB stick in your PC and copy dropbear to the main directory: 
 + 
 +  cp output/target/usr/sbin/dropbear /media/$USER/USBSTOR/ 
 + 
 +Replace USBSTOR with the name of the USB stick.  
 + 
 +Write following script to the main directory of the USB stick with the name flashforge_init.sh
  
-In the ELF file of the play application, following library defines are shown: 
 <code bash> <code bash>
-        000107c6 ds "GCC_3.5" +#!/bin/sh 
-        000107ce ds "GLIBC_2.4+set -x 
-        000107d8 ds "CXXABI_1.3+ 
-        000107e3 ds "GLIBCXX_3.4"+WORK_DIR=`dirname $0` 
 + 
 +MACHINE=Creator3Pro 
 +PID=0014 
 + 
 +#Test the machine's architecture and quit immediately if there's an error. 
 +CHECK_ARCH=`uname -m` 
 +if [ "${CHECK_ARCH}" != "armv7l" ];then 
 +    echo "Machine architecture error.
 +    echo ${CHECK_ARCH} 
 +    exit 1 
 +fi 
 + 
 + 
 +cat $WORK_DIR/start.img > /dev/fb0 
 + 
 +#create_key 
 +# 1. copy dropbear to /usr/sbin/ 
 +cp $WORK_DIR/dropbear /usr/sbin/dropbear 
 +chmod 755 /usr/sbin/dropbear 
 + 
 +# 2. create a symlink dropbearkey and dropbearconvert to dropbear in /usr/sbin 
 +ln -s /usr/bin/dropbearkey /usr/sbin/dropbear 
 +ln -s /usr/bin/dropbearconvert /usr/sbin/dropbear 
 + 
 +# 3. create a symlink scp to dropbear in /usr/bin 
 +ln -s /usr/sbin/dropbear /usr/bin/scp 
 + 
 +# 4. create rsa key in /etc/dropbear/ (e.g. /etc/dropbear/dropbear_rsa_host_key) 
 +mkdir -p /etc/dropbear 
 +dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key 
 + 
 +5. Add dropbear as an init.d script 
 +cat << 'EOF' > /etc/init.d/S50dropbear 
 +#!/bin/sh 
 +
 +# S50dropbear        Starts dropbear. 
 +
 +# please note: if not added in rcS like: 
 +# ifconfig eth0 hw ether 88:A9:A7:93:CD:EF 
 +# the MAC address may change everytime when the board restarts. 
 + 
 +# Make sure dropbearkey exists 
 +[ -f /usr/bin/dropbearkey ] || exit 0 
 + 
 +# Make sure dropbear exists 
 +[ -f /usr/sbin/dropbear ] || exit 0 
 + 
 +SSH_HOST_KEY=/etc/dropbear/dropbear_rsa_host_key 
 + 
 +umask 077 
 + 
 +start() { 
 +    # check for public key, ssh-rsa type and for fingerprint 
 +    if /usr/bin/dropbearkey -y -f ${SSH_HOST_KEY} | grep -q "Public key portion is" && 
 +      /usr/bin/dropbearkey -y -f ${SSH_HOST_KEY} | grep -q "ssh-rsa&& 
 +        /usr/bin/dropbearkey -y -f ${SSH_HOST_KEY} | grep -q "Fingerprint"; then 
 +      printf "Starting sshd: " 
 +      /usr/sbin/dropbear 
 +      touch /run/dropbear.pid 
 +      echo "OK
 +    else 
 +      # Create any missing keys 
 +      printf "Creating ssh keys..." 
 +      mkdir -p /etc/dropbear 
 +      /usr/bin/dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key 
 +      start 
 +    fi 
 +
 +stop() { 
 + printf "Stopping dropbear: " 
 + killall dropbear 
 + rm -f /run/dropbear.pid 
 + echo "OK" 
 +
 +restart() { 
 + stop 
 + start 
 +
 + 
 +case "$1" in 
 +  start) 
 + start 
 + ;; 
 +  stop) 
 + stop 
 + ;; 
 +  restart|reload) 
 + restart 
 + ;; 
 +  *) 
 + echo "Usage: $0 {start|stop|restart}" 
 + exit 1 
 +esac 
 + 
 +exit $? 
 +EOF 
 + 
 +# 6. set file permissions for S50dropbear 
 +chmod 755 /etc/init.d/S50dropbear 
 + 
 +sync 
 +cat $WORK_DIR/end.img > /dev/fb0 
 + 
 +$WORK_DIR/play 
 + 
 +exit 0 
 +EOF 
 + 
 +# 6. set file permissions for S50dropbear 
 +chmod 755 /etc/init.d/S50dropbear 
 + 
 +sync 
 +cat $WORK_DIR/end.img > /dev/fb0 
 + 
 +$WORK_DIR/play 
 + 
 +exit 0
 </code> </code>
 +
 +
 +After copying dropbear and flashforge_init.sh to a USB stick, download the following files from [[https://drive.google.com/file/d/11mXjpSDyMnloJLvtLTWBgSO6f1Hx_eiH/view?usp=drive_link|the official Flashforge 1.4.0 release]] and copy them to the USB stick as well.
 +  * 0014
 +  * end.img
 +  * play
 +  * start.img
 +  * version.cfg
 +
 +Alternatively you may download all the files together in one tar.bz2 archive from here [[https://www.auditeon.com/xyz/flashforge_dropbear_files.tar.bz2|flashforge_dropbear_files.tar.bz2]] and extract them to the USB stick.
 +
 +===== Install dropbear to the printer =====
 +  - Power off the printer
 +  - Insert the stick in the printer and power it on again.
 +  - After a few seconds dropbear should be installed.
 +  - Switch off the printer once again, remove the USB stick
 +  - Power on again. Dropbear should now be ready for use.
 +
 +Test the ssh connection to the printer with following user: root\\ 
 +The password for user root you should have already modified as described in the [[projects:3dprinting:flashforge_creator_3_pro_fan_fix:root_access|following page]].
projects/3dprinting/flashforge_creator_3_pro_fan_fix/dropbear.1729697821.txt.gz · Last modified: 2024/10/23 17:37 by admin