ubuntu: add ubuntu support

Signed-off-by: eng33 <eng33@luckfox.com>
This commit is contained in:
eng33
2023-12-11 17:12:47 +08:00
committed by luckfox-eng33
parent 5532a62450
commit 226c3fbda8
34 changed files with 6250 additions and 204 deletions

View File

@@ -98,6 +98,29 @@ endif
ifneq ($(OUTPUT_SYSDRV_RAMDISK_DIR),)
SYSDRV_BUILD_RAMDISK_FLAG := YES
endif
################################################################################
## rootfs Select
################################################################################
ifneq ($(LF_TARGET_ROOTFS),)
TARGET_ROOTFS := $(LF_TARGET_ROOTFS)
else
# TARGET_ROOTFS := ubuntu
TARGET_ROOTFS := buildroot
# TARGET_ROOTFS := busybox
# TARGET_ROOTFS := custom
endif
ifneq ($(findstring $(TARGET_ROOTFS),custom),)
ROOTFS_BUILD_ENV :=
else ifneq ($(findstring $(TARGET_ROOTFS),ubuntu),)
ROOTFS_BUILD_ENV := ubuntu
else ifneq ($(findstring $(TARGET_ROOTFS),buildroot),)
ROOTFS_BUILD_ENV := rootfs_prepare pctools buildroot boardtools drv
else
ROOTFS_BUILD_ENV := rootfs_prepare pctools busybox boardtools drv
endif
################################################################################
## Public Configuraton
################################################################################
@@ -227,12 +250,17 @@ else
$(error Please config TINY_ROOTFS_BUSYBOX_CFG on cfg/cfg.mk)
endif
endif
BUSYBOX_CFG ?= config_normal
BUSYBOX_VER ?= busybox-1.27.2
BUSYBOX_DIR ?= $(SYSDRV_DIR)/source/busybox
BUILDROOT_CFG ?= config_normal
BUILDROOT_VER ?= buildroot-2023.02.6
BUILDROOT_DIR := $(SYSDRV_DIR)/source/buildroot
UBUNTU_VER ?= luckfox-ubuntu-22.04.3
TOOLCHAIN_RUNTIME_LIB_C:=lib.tar.bz2
EXT4_TOOL:=mkfs_ext4.sh
@@ -433,6 +461,49 @@ rootfs_prepare: prepare
$(SYSDRV_DIR_OUT_BOARD); \
popd
##########################################################################################
# build busybox
##########################################################################################
busybox_menuconfig:
@$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) menuconfig \
-C $(BUSYBOX_DIR)/$(BUSYBOX_VER)/
@cp -f $(BUSYBOX_DIR)/$(BUSYBOX_VER)/.config \
$(SYSDRV_DIR)/tools/board/busybox/$(BUSYBOX_CFG);
busybox: prepare
@echo -e "$(C_GREEN) ==sysdrv== build busybox $(C_NORMAL)"
test -f $(BUSYBOX_DIR)/$(BUSYBOX_VER)/_install/bin/busybox || (\
rm $(BUSYBOX_DIR)/$(BUSYBOX_VER) -rf ;\
mkdir -p $(BUSYBOX_DIR) ;\
tar xjf $(SYSDRV_DIR)/tools/board/busybox/$(BUSYBOX_VER).tar.bz2 -C $(BUSYBOX_DIR) ;\
cp $(SYSDRV_DIR)/tools/board/busybox/$(BUSYBOX_CFG) $(BUSYBOX_DIR)/$(BUSYBOX_VER)/.config ;\
cp -fv $(SYSDRV_DIR)/tools/board/busybox/*.patch $(SYSDRV_DIR)/tools/board/busybox/busybox.patch.sh $(BUSYBOX_DIR)/$(BUSYBOX_VER)/ ;\
pushd $(BUSYBOX_DIR)/$(BUSYBOX_VER)/;$(SHELL) ./busybox.patch.sh ; $(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -j$(SYSDRV_JOBS) ; popd ;\
$(MAKE) CROSS_COMPILE=$(CROSS_COMPILE) -C $(BUSYBOX_DIR)/$(BUSYBOX_VER) install ;\
);
ifeq ($(SYSDRV_BUILD_RAMDISK_FLAG),YES)
tar xf $(SYSDRV_DIR)/tools/board/rootfs_script.tar -C $(BUSYBOX_DIR)/$(BUSYBOX_VER)/_install
ifneq ($(OUTPUT_SYSDRV_RAMDISK_TINY_ROOTFS_DIR),)
$(call MAROC_COPY_PKG_TO_SYSDRV_OUTPUT, $(OUTPUT_SYSDRV_RAMDISK_TINY_ROOTFS_DIR), \
$(SYSDRV_DIR)/tools/board/busybox/init \
$(BUSYBOX_DIR)/$(BUSYBOX_VER)/_install)
else
$(call MAROC_COPY_PKG_TO_SYSDRV_OUTPUT, $(SYSDRV_DIR_OUT_ROOTFS), \
$(SYSDRV_DIR)/tools/board/busybox/init \
$(BUSYBOX_DIR)/$(BUSYBOX_VER)/_install)
endif
else
cp -af $(BUSYBOX_DIR)/$(BUSYBOX_VER)/_install/* $(SYSDRV_DIR_OUT_ROOTFS)
# luckfox
cp $(SYSDRV_DIR)/tools/board/android-tools/S90usb0config $(SYSDRV_DIR_OUT_ROOTFS)/etc/init.d
touch $(SYSDRV_DIR_OUT_ROOTFS)/userdata/.busybox
endif
busybox_clean:
$(AT)rm -rf $(BUSYBOX_DIR)/$(BUSYBOX_VER)
##########################################################################################
# build buildroot
# author :luckfox team
@@ -452,6 +523,7 @@ buildroot: prepare
mkdir -p $(BUILDROOT_DIR) ;\
tar xzf $(SYSDRV_DIR)/tools/board/buildroot/$(BUILDROOT_VER).tar.gz -C $(BUILDROOT_DIR) ;\
cp $(SYSDRV_DIR)/tools/board/buildroot/luckfox_pico_defconfig $(BUILDROOT_DIR)/$(BUILDROOT_VER)/configs/ ;\
cp $(SYSDRV_DIR)/tools/board/buildroot/busybox.config $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/busybox/ ;\
);
$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) $(BUILDROOT_DEFCONFIG) -C $(BUILDROOT_DIR)/$(BUILDROOT_VER)
@@ -470,7 +542,13 @@ ifeq ($(SYSDRV_BUILD_RAMDISK_FLAG),YES)
$(BUILDROOT_DIR)/$(BUILDROOT_VER)/output/target)
endif
else
test -f $(SYSDRV_DIR_OUT_ROOTFS)/userdata/.buildroot || (\
rm -rf $(SYSDRV_DIR_OUT_ROOTFS) ;\
mkdir -p $(SYSDRV_DIR_OUT_ROOTFS) ;\
);
tar xf $(BUILDROOT_DIR)/$(BUILDROOT_VER)/output/images/rootfs.tar -C $(SYSDRV_DIR_OUT_ROOTFS)
mkdir -p $(SYSDRV_DIR_OUT_ROOTFS)/userdata
touch $(SYSDRV_DIR_OUT_ROOTFS)/userdata/.buildroot
cp $(SYSDRV_DIR)/tools/board/buildroot/shadow_defconfig $(SYSDRV_DIR_OUT_ROOTFS)/etc/shadow
cp $(SYSDRV_DIR)/tools/board/buildroot/sshd_defconfig $(SYSDRV_DIR_OUT_ROOTFS)/etc/ssh/sshd_config
cp $(SYSDRV_DIR)/tools/board/buildroot/samba_defconfig $(SYSDRV_DIR_OUT_ROOTFS)/etc/samba/smb.conf
@@ -478,12 +556,33 @@ else
cp $(SYSDRV_DIR)/tools/board/buildroot/S50sshd $(SYSDRV_DIR_OUT_ROOTFS)/etc/init.d/
cp $(SYSDRV_DIR)/tools/board/buildroot/S99python $(SYSDRV_DIR_OUT_ROOTFS)/etc/init.d/
cp $(SYSDRV_DIR)/tools/board/android-tools/S90usb0config $(SYSDRV_DIR_OUT_ROOTFS)/etc/init.d/
endif
buildroot_clean:
$(AT)rm -rf $(BUILDROOT_DIR)/$(BUILDROOT_VER)
##########################################################################################
# build ubuntu
# author :luckfox team
# date:2023-11-28
##########################################################################################
ubuntu: prepare
@echo -e "$(C_GREEN) ==sysdrv== build ubuntu $(C_NORMAL)"
echo "====$(LF_TARGET_ROOTFS)===="
test -f $(SYSDRV_DIR)/tools/board/ubuntu/$(UBUNTU_VER).tar.gz || (\
pushd $(SYSDRV_DIR)/tools/board/ubuntu/ ;\
./split_and_check_md5.sh merge ./$(UBUNTU_VER).tar.gz ;\
popd ;\
);
test -f $(SYSDRV_DIR_OUT_ROOTFS)/userdate/.ubuntu || (\
mkdir -p $(SYSDRV_DIR_OUT_ROOTFS) ;\
rm $(SYSDRV_DIR_OUT_ROOTFS)/* -rf ;\
tar xzf $(SYSDRV_DIR)/tools/board/ubuntu/$(UBUNTU_VER).tar.gz -C $(SYSDRV_DIR_OUT_ROOTFS) ;\
);
ubuntu_clean:
$(AT)rm -rf $(UBUNTU_DIR)/$(UBUNTU_VER)
##########################################################################################
# build pc tools
##########################################################################################
@@ -529,7 +628,7 @@ drv_clean:
##########################################################################################
# build rootfs
##########################################################################################
rootfs: rootfs_prepare pctools buildroot boardtools drv
rootfs: $(ROOTFS_BUILD_ENV)
@echo -e "$(C_GREEN) ==sysdrv== build rootfs $(C_NORMAL)"
make -C $(SYSDRV_DIR) strip
pushd $(SYSDRV_DIR)/out;tar cf $(OUT_ROOTFS).tar $(OUT_ROOTFS);popd

View File

@@ -0,0 +1,185 @@
// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
* Copyright (c) 2022 Rockchip Electronics Co., Ltd.
*/
/dts-v1/;
#include "rv1103.dtsi"
#include "rv1106-evb.dtsi"
#include "rv1103-luckfox-pico-plus-ipc.dtsi"
/ {
model = "Luckfox Pico Plus";
compatible = "rockchip,rv1103g-38x38-ipc-v10", "rockchip,rv1103";
};
/**********SDMMC**********/
&sdmmc {
max-frequency = <50000000>;
no-sdio;
no-mmc;
bus-width = <4>;
cap-mmc-highspeed;
cap-sd-highspeed;
disable-wp;
pinctrl-names = "default";
pinctrl-0 = <&sdmmc0_clk &sdmmc0_cmd &sdmmc0_det &sdmmc0_bus4>;
status = "okay";
};
/**********SFC**********/
&sfc {
status = "okay";
flash@0 {
compatible = "spi-nand";
reg = <0>;
spi-max-frequency = <75000000>;
spi-rx-bus-width = <4>;
spi-tx-bus-width = <1>;
};
};
/**********ETH**********/
&gmac {
status = "okay";
};
/**********USB**********/
//&usbdrd {
// status = "disabled";
//};
//&usbdrd_dwc3 {
// status = "disabled";
//};
//&u2phy {
// status = "disabled";
//};
//&u2phy_otg {
// status = "disabled";
//};
/**********I2C**********/
// &i2c0 {
// status = "okay";
// pinctrl-0 = <&i2c0m2_xfer>;
// clock-frequency = <100000>;
// };
&i2c3 {
status = "okay";
pinctrl-0 = <&i2c3m1_xfer>;
clock-frequency = <100000>;
};
/**********SPI**********/
&spi0 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&spi0m0_pins>;
cs-gpios = <&gpio1 RK_PC0 1>;
// cs-gpios = <&gpio1 26 1>;
#address-cells = <1>;
#size-cells = <0>;
spidev@0 {
compatible = "rockchip,spidev";
spi-max-frequency = <1000000000>;
reg = <0>;
};
};
/**********UART**********/
&uart3 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&uart3m1_xfer>;
};
&uart4 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&uart4m1_xfer>;
};
//&uart5 {
// status = "okay";
// pinctrl-names = "default";
// pinctrl-0 = <&uart5m0_xfer>;
//};
/**********PWM**********/
&pwm0 {
status = "okay";
pinctrl-names = "active";
pinctrl-0 = <&pwm0m0_pins>;
// pinctrl-0 = <&pwm0m1_pins>;
};
&pwm1 {
status = "okay";
pinctrl-names = "active";
pinctrl-0 = <&pwm1m0_pins>;
// pinctrl-0 = <&pwm1m1_pins>;
};
//&pwm2 {
// status = "okay";
// pinctrl-names = "active";
// pinctrl-0 = <&pwm2m2_pins>;
//};
//&pwm3 {
// status = "okay";
// pinctrl-names = "active";
// pinctrl-0 = <&pwm3m2_pins>;
//};
//&pwm4 {
// status = "okay";
// pinctrl-names = "active";
// pinctrl-0 = <&pwm4m2_pins>;
//};
//&pwm5 {
// status = "okay";
// pinctrl-names = "active";
// pinctrl-0 = <&pwm5m2_pins>;
//};
//&pwm6 {
// status = "okay";
// pinctrl-names = "active";
// pinctrl-0 = <&pwm6m2_pins>;
//};
//&pwm7 {
// status = "okay";
// pinctrl-names = "active";
// pinctrl-0 = <&pwm7m2_pins>;
//};
//&pwm8 {
// status = "okay";
// pinctrl-names = "active";
// // pinctrl-0 = <&pwm8m1_pins>;
// pinctrl-0 = <&pwm8m0_pins>;
//};
//&pwm9 {
// status = "okay";
// pinctrl-names = "active";
// // pinctrl-0 = <&pwm9m1_pins>;
// pinctrl-0 = <&pwm9m0_pins>;
//};
&pwm10 {
status = "okay";
pinctrl-names = "active";
pinctrl-0 = <&pwm10m1_pins>;
// pinctrl-0 = <&pwm10m2_pins>;
// pinctrl-0 = <&pwm10m0_pins>;
};
&pwm11 {
status = "okay";
pinctrl-names = "active";
pinctrl-0 = <&pwm11m1_pins>;
// pinctrl-0 = <&pwm11m2_pins>;
// pinctrl-0 = <&pwm11m0_pins>;
};

View File

@@ -1,12 +1,13 @@
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_KERNEL_XZ=y
CONFIG_DEFAULT_HOSTNAME="localhost"
# CONFIG_SWAP is not set
CONFIG_SYSVIPC=y
CONFIG_NO_HZ=y
CONFIG_HIGH_RES_TIMERS=y
CONFIG_PREEMPT_VOLUNTARY=y
CONFIG_LOG_BUF_SHIFT=14
CONFIG_CGROUPS=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
# CONFIG_BUG is not set
# CONFIG_BASE_FULL is not set
@@ -67,6 +68,8 @@ CONFIG_MTD_SPI_NOR=y
CONFIG_MTD_SPI_NOR_MISC=y
CONFIG_MTD_UBI=y
CONFIG_MTD_UBI_BLOCK=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_RAM=y
CONFIG_NETDEVICES=y
# CONFIG_NET_CORE is not set
# CONFIG_NET_VENDOR_ALACRITECH is not set
@@ -151,6 +154,7 @@ CONFIG_SPI=y
CONFIG_SPI_ROCKCHIP=y
CONFIG_SPI_ROCKCHIP_SFC=y
CONFIG_SPI_SPIDEV=y
CONFIG_SPI_SLAVE=y
# CONFIG_PTP_1588_CLOCK is not set
CONFIG_GPIO_SYSFS=y
CONFIG_POWER_RESET=y
@@ -289,7 +293,6 @@ CONFIG_EXT4_FS=y
CONFIG_EXPORTFS_BLOCK_OPS=y
# CONFIG_DNOTIFY is not set
CONFIG_VFAT_FS=y
CONFIG_EXFAT_FS=y
CONFIG_TMPFS=y
CONFIG_JFFS2_FS=y
CONFIG_JFFS2_COMPRESSION_OPTIONS=y

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,29 @@
From d4fec31889ad660a58dab633c511221feb66e817 Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Date: Sat, 5 Oct 2013 15:55:06 +0200
Subject: [PATCH] networking/libiproute: use <linux/if_packet.h> instead of
<net/if_packet.h>
The musl C library doesn't provide the <net/if_packet.h> since the
corresponding kernel headers <linux/if_packet.h> already provides the
necessary definitions. Replacing <net/if_packet.h> by
<linux/if_packet.h> also removes the need to include
<netpacket/packet.h>
This commit fixes the build of iplink with the musl C library.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
[Gustavo: update for busybox 1.22.0]
diff -Nura busybox-1.22.0.orig/networking/libiproute/iplink.c busybox-1.22.0/networking/libiproute/iplink.c
--- busybox-1.22.0.orig/networking/libiproute/iplink.c 2014-01-01 09:42:40.301137882 -0300
+++ busybox-1.22.0/networking/libiproute/iplink.c 2014-01-01 09:43:01.282827700 -0300
@@ -7,7 +7,7 @@
*/
#include <net/if.h>
/*#include <net/if_packet.h> - not needed? */
-#include <netpacket/packet.h>
+#include <linux/if_packet.h>
#include <netinet/if_ether.h>
#include <linux/if_vlan.h>

View File

@@ -0,0 +1,28 @@
From 67eb23d2be8aba3c474dac81a15b0fa11e5847b7 Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Date: Mon, 25 Nov 2013 22:51:53 +0100
Subject: [PATCH] Makefile.flags: strip non -l arguments returned by pkg-config
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
Makefile.flags | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Makefile.flags b/Makefile.flags
index 307afa7..885e323 100644
--- a/Makefile.flags
+++ b/Makefile.flags
@@ -141,7 +141,9 @@ ifeq ($(CONFIG_SELINUX),y)
SELINUX_PC_MODULES = libselinux libsepol
$(eval $(call pkg_check_modules,SELINUX,$(SELINUX_PC_MODULES)))
CPPFLAGS += $(SELINUX_CFLAGS)
-LDLIBS += $(if $(SELINUX_LIBS),$(SELINUX_LIBS:-l%=%),$(SELINUX_PC_MODULES:lib%=%))
+LDLIBS += $(if $(SELINUX_LIBS),\
+ $(patsubst -l%,%,$(filter -l%,$(SELINUX_LIBS))),\
+ $(SELINUX_PC_MODULES:lib%=%))
endif
ifeq ($(CONFIG_EFENCE),y)
--
1.8.1.2

View File

@@ -0,0 +1,46 @@
From 2c240f131ae5cc981702b45397be3b311c67a9ee Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Date: Fri, 14 Jul 2017 22:23:46 +0200
Subject: [PATCH] Makefile: include per-arch Makefile before Makefile.flags
Makefile.flags contains:
ARCH_FPIC ?= -fpic
ARCH_FPIE ?= -fpie
However, arch/$(ARCH)/Makefile gets included *after* Makefile.flags,
and therefore doesn't get the chance to provide its own value.
Fix this by including arch/$(ARCH)/Makefile *before* Makefile.flags.
[Submitted upstream: http://lists.busybox.net/pipermail/busybox/2017-July/085632.html]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 971e68e..fe85070 100644
--- a/Makefile
+++ b/Makefile
@@ -508,6 +508,8 @@ ifeq ($(dot-config),1)
# To avoid any implicit rule to kick in, define an empty command
.config .kconfig.d: ;
+-include $(srctree)/arch/$(ARCH)/Makefile
+
# Now we can define CFLAGS etc according to .config
include $(srctree)/Makefile.flags
@@ -531,8 +533,6 @@ endif
# Defaults busybox but it is usually overridden in the arch makefile
all: busybox doc
--include $(srctree)/arch/$(ARCH)/Makefile
-
# arch Makefile may override CC so keep this after arch Makefile is included
#bbox# NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
CHECKFLAGS += $(NOSTDINC_FLAGS)
--
2.9.4

View File

@@ -0,0 +1,79 @@
From 43593d65827f4e7f848fc410321b0b2deed986fc Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Date: Fri, 14 Jul 2017 21:54:37 +0200
Subject: [PATCH] arch/{sparc,sparc64}/Makefile: define ARCH_FPIC
Building Busybox on SPARC or SPARC64 with CONFIG_BUILD_LIBBUSYBOX=y
currently fails with:
miscutils/lib.a(i2c_tools.o): In function `i2c_dev_open':
i2c_tools.c:(.text.i2c_dev_open+0x14): relocation truncated to fit: R_SPARC_GOT13 against `.LC0'
i2c_tools.c:(.text.i2c_dev_open+0x38): relocation truncated to fit: R_SPARC_GOT13 against symbol `bb_errno' defined in COMMON section in libbb/lib.a(ptr_to_globals.o)
i2c_tools.c:(.text.i2c_dev_open+0x6c): relocation truncated to fit: R_SPARC_GOT13 against `.LC1'
miscutils/lib.a(i2c_tools.o): In function `check_funcs_test_end':
i2c_tools.c:(.text.check_funcs_test_end+0x24): relocation truncated to fit: R_SPARC_GOT13 against `.LC2'
i2c_tools.c:(.text.check_funcs_test_end+0x2c): relocation truncated to fit: R_SPARC_GOT13 against `.LC3'
miscutils/lib.a(i2c_tools.o): In function `check_read_funcs':
i2c_tools.c:(.text.check_read_funcs+0x30): relocation truncated to fit: R_SPARC_GOT13 against `.LC10'
i2c_tools.c:(.text.check_read_funcs+0x80): relocation truncated to fit: R_SPARC_GOT13 against `.LC4'
i2c_tools.c:(.text.check_read_funcs+0x98): relocation truncated to fit: R_SPARC_GOT13 against `.LC5'
i2c_tools.c:(.text.check_read_funcs+0xc0): relocation truncated to fit: R_SPARC_GOT13 against `.LC6'
i2c_tools.c:(.text.check_read_funcs+0xe0): relocation truncated to fit: R_SPARC_GOT13 against `.LC7'
i2c_tools.c:(.text.check_read_funcs+0xf8): additional relocation overflows omitted from the output
As stated by the gcc documentation, the SPARC architecture has a
limited GOT size, which prevents moderately large binaries to be built
with -fpic, and -fPIC is necessary. From gcc's documentation:
'-fpic'
Generate position-independent code (PIC) suitable for use in a
shared library, if supported for the target machine. Such code
accesses all constant addresses through a global offset table
(GOT). The dynamic loader resolves the GOT entries when the
program starts (the dynamic loader is not part of GCC; it is part
of the operating system). If the GOT size for the linked
executable exceeds a machine-specific maximum size, you get an
error message from the linker indicating that '-fpic' does not
work; in that case, recompile with '-fPIC' instead. (These
maximums are 8k on the SPARC, 28k on AArch64 and 32k on the m68k
and RS/6000. The x86 has no such limit.)
'-fPIC'
If supported for the target machine, emit position-independent
code, suitable for dynamic linking and avoiding any limit on the
size of the global offset table. This option makes a difference on
AArch64, m68k, PowerPC and SPARC.
With a limit of 8KB on SPARC, we quickly reach this limit, and we hit
it when building Busybox on SPARC/SPARC64 with the
CONFIG_BUILD_LIBBUSYBOX=y option enabled.
Therefore, this commit redefines ARCH_FPIC as -fPIC on sparc and
sparc64 to solve this issue.
[Submitted upstream: http://lists.busybox.net/pipermail/busybox/2017-July/085633.html]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
arch/sparc/Makefile | 1 +
arch/sparc64/Makefile | 1 +
2 files changed, 2 insertions(+)
create mode 100644 arch/sparc/Makefile
create mode 100644 arch/sparc64/Makefile
diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile
new file mode 100644
index 0000000..4d6c5fb
--- /dev/null
+++ b/arch/sparc/Makefile
@@ -0,0 +1 @@
+ARCH_FPIC = -fPIC
diff --git a/arch/sparc64/Makefile b/arch/sparc64/Makefile
new file mode 100644
index 0000000..4d6c5fb
--- /dev/null
+++ b/arch/sparc64/Makefile
@@ -0,0 +1 @@
+ARCH_FPIC = -fPIC
--
2.9.4

View File

@@ -0,0 +1,27 @@
From 2b400d9b2b7309d6e479102fc3ce646e893058a5 Mon Sep 17 00:00:00 2001
From: Denys Vlasenko <vda.linux@googlemail.com>
Date: Mon, 18 Sep 2017 13:09:11 +0200
Subject: [PATCH] httpd: fix handling of range requests
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
---
networking/httpd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/networking/httpd.c b/networking/httpd.c
index e072f23c7..5e32fc936 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -2337,7 +2337,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
if (STRNCASECMP(iobuf, "Range:") == 0) {
/* We know only bytes=NNN-[MMM] */
char *s = skip_whitespace(iobuf + sizeof("Range:")-1);
- if (is_prefixed_with(s, "bytes=") == 0) {
+ if (is_prefixed_with(s, "bytes=")) {
s += sizeof("bytes=")-1;
range_start = BB_STRTOOFF(s, &s, 10);
if (s[0] != '-' || range_start < 0) {
--
2.11.0

View File

@@ -0,0 +1,101 @@
From 0402cb32df015d9372578e3db27db47b33d5c7b0 Mon Sep 17 00:00:00 2001
From: Denys Vlasenko <vda.linux@googlemail.com>
Date: Sun, 22 Oct 2017 18:23:23 +0200
Subject: [PATCH] bunzip2: fix runCnt overflow from bug 10431
This particular corrupted file can be dealth with by using "unsigned".
If there will be cases where it genuinely overflows, there is a disabled
code to deal with that too.
function old new delta
get_next_block 1678 1667 -11
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
Patch status: upstream commit 0402cb32df0
archival/libarchive/decompress_bunzip2.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/archival/libarchive/decompress_bunzip2.c b/archival/libarchive/decompress_bunzip2.c
index 7cd18f5ed4cf..bec89edd3a4d 100644
--- a/archival/libarchive/decompress_bunzip2.c
+++ b/archival/libarchive/decompress_bunzip2.c
@@ -156,15 +156,15 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted)
static int get_next_block(bunzip_data *bd)
{
struct group_data *hufGroup;
- int dbufCount, dbufSize, groupCount, *base, *limit, selector,
- i, j, runPos, symCount, symTotal, nSelectors, byteCount[256];
- int runCnt = runCnt; /* for compiler */
+ int groupCount, *base, *limit, selector,
+ i, j, symCount, symTotal, nSelectors, byteCount[256];
uint8_t uc, symToByte[256], mtfSymbol[256], *selectors;
uint32_t *dbuf;
unsigned origPtr, t;
+ unsigned dbufCount, runPos;
+ unsigned runCnt = runCnt; /* for compiler */
dbuf = bd->dbuf;
- dbufSize = bd->dbufSize;
selectors = bd->selectors;
/* In bbox, we are ok with aborting through setjmp which is set up in start_bunzip */
@@ -187,7 +187,7 @@ static int get_next_block(bunzip_data *bd)
it didn't actually work. */
if (get_bits(bd, 1)) return RETVAL_OBSOLETE_INPUT;
origPtr = get_bits(bd, 24);
- if ((int)origPtr > dbufSize) return RETVAL_DATA_ERROR;
+ if (origPtr > bd->dbufSize) return RETVAL_DATA_ERROR;
/* mapping table: if some byte values are never used (encoding things
like ascii text), the compression code removes the gaps to have fewer
@@ -435,7 +435,14 @@ static int get_next_block(bunzip_data *bd)
symbols, but a run of length 0 doesn't mean anything in this
context). Thus space is saved. */
runCnt += (runPos << nextSym); /* +runPos if RUNA; +2*runPos if RUNB */
- if (runPos < dbufSize) runPos <<= 1;
+//The 32-bit overflow of runCnt wasn't yet seen, but probably can happen.
+//This would be the fix (catches too large count way before it can overflow):
+// if (runCnt > bd->dbufSize) {
+// dbg("runCnt:%u > dbufSize:%u RETVAL_DATA_ERROR",
+// runCnt, bd->dbufSize);
+// return RETVAL_DATA_ERROR;
+// }
+ if (runPos < bd->dbufSize) runPos <<= 1;
goto end_of_huffman_loop;
}
@@ -445,14 +452,15 @@ static int get_next_block(bunzip_data *bd)
literal used is the one at the head of the mtfSymbol array.) */
if (runPos != 0) {
uint8_t tmp_byte;
- if (dbufCount + runCnt > dbufSize) {
- dbg("dbufCount:%d+runCnt:%d %d > dbufSize:%d RETVAL_DATA_ERROR",
- dbufCount, runCnt, dbufCount + runCnt, dbufSize);
+ if (dbufCount + runCnt > bd->dbufSize) {
+ dbg("dbufCount:%u+runCnt:%u %u > dbufSize:%u RETVAL_DATA_ERROR",
+ dbufCount, runCnt, dbufCount + runCnt, bd->dbufSize);
return RETVAL_DATA_ERROR;
}
tmp_byte = symToByte[mtfSymbol[0]];
byteCount[tmp_byte] += runCnt;
- while (--runCnt >= 0) dbuf[dbufCount++] = (uint32_t)tmp_byte;
+ while ((int)--runCnt >= 0)
+ dbuf[dbufCount++] = (uint32_t)tmp_byte;
runPos = 0;
}
@@ -466,7 +474,7 @@ static int get_next_block(bunzip_data *bd)
first symbol in the mtf array, position 0, would have been handled
as part of a run above. Therefore 1 unused mtf position minus
2 non-literal nextSym values equals -1.) */
- if (dbufCount >= dbufSize) return RETVAL_DATA_ERROR;
+ if (dbufCount >= bd->dbufSize) return RETVAL_DATA_ERROR;
i = nextSym - 1;
uc = mtfSymbol[i];
--
2.15.1

View File

@@ -0,0 +1,34 @@
From 9ac42c500586fa5f10a1f6d22c3f797df11b1f6b Mon Sep 17 00:00:00 2001
From: Denys Vlasenko <vda.linux@googlemail.com>
Date: Fri, 27 Oct 2017 15:37:03 +0200
Subject: [PATCH] unlzma: fix SEGV, closes 10436
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
Patch status: upstream commit 9ac42c500586f
archival/libarchive/decompress_unlzma.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/archival/libarchive/decompress_unlzma.c b/archival/libarchive/decompress_unlzma.c
index a9040877efa0..be4342414435 100644
--- a/archival/libarchive/decompress_unlzma.c
+++ b/archival/libarchive/decompress_unlzma.c
@@ -450,8 +450,12 @@ unpack_lzma_stream(transformer_state_t *xstate)
IF_NOT_FEATURE_LZMA_FAST(string:)
do {
uint32_t pos = buffer_pos - rep0;
- if ((int32_t)pos < 0)
+ if ((int32_t)pos < 0) {
pos += header.dict_size;
+ /* bug 10436 has an example file where this triggers: */
+ if ((int32_t)pos < 0)
+ goto bad;
+ }
previous_byte = buffer[pos];
IF_NOT_FEATURE_LZMA_FAST(one_byte2:)
buffer[buffer_pos++] = previous_byte;
--
2.15.1

View File

@@ -0,0 +1,58 @@
From 095248c1d232c147f53d4c8666b80b4c1cbb2d2a Mon Sep 17 00:00:00 2001
From: "hero.huang" <hero.huang@rock-chips.com>
Date: Wed, 23 Aug 2017 11:33:47 +0800
Subject: [PATCH] busybox: support chinese display in terminal
Signed-off-by: hero.huang <hero.huang@rock-chips.com>
---
libbb/printable_string.c | 4 +---
libbb/unicode.c | 4 ++--
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/libbb/printable_string.c b/libbb/printable_string.c
index 077d58d..e7399ae 100644
--- a/libbb/printable_string.c
+++ b/libbb/printable_string.c
@@ -28,8 +28,6 @@ const char* FAST_FUNC printable_string(uni_stat_t *stats, const char *str)
}
if (c < ' ')
break;
- if (c >= 0x7f)
- break;
s++;
}
@@ -42,7 +40,7 @@ const char* FAST_FUNC printable_string(uni_stat_t *stats, const char *str)
unsigned char c = *d;
if (c == '\0')
break;
- if (c < ' ' || c >= 0x7f)
+ if (c < ' ')
*d = '?';
d++;
}
diff --git a/libbb/unicode.c b/libbb/unicode.c
index 9c4da50..c7eba06 100644
--- a/libbb/unicode.c
+++ b/libbb/unicode.c
@@ -1019,7 +1019,7 @@ static char* FAST_FUNC unicode_conv_to_printable2(uni_stat_t *stats, const char
while ((int)--width >= 0);
break;
}
- *d++ = (c >= ' ' && c < 0x7f) ? c : '?';
+ *d++ = (c >= ' ') ? c : '?';
src++;
}
*d = '\0';
@@ -1027,7 +1027,7 @@ static char* FAST_FUNC unicode_conv_to_printable2(uni_stat_t *stats, const char
d = dst = xstrndup(src, width);
while (*d) {
unsigned char c = *d;
- if (c < ' ' || c >= 0x7f)
+ if (c < ' ')
*d = '?';
d++;
}
--
1.9.1

View File

@@ -0,0 +1,88 @@
From e9e7cce0cdbd50afa6db7748546d76f0280c1756 Mon Sep 17 00:00:00 2001
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Date: Tue, 18 Sep 2018 11:32:04 +0800
Subject: [PATCH] halt: Support rebooting with arg
Support passing reboot arg(e.g. loader, fastboot, etc.) to kernel.
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
init/halt.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/init/halt.c b/init/halt.c
index f69b897..523c925 100644
--- a/init/halt.c
+++ b/init/halt.c
@@ -83,6 +83,8 @@
#include "libbb.h"
#include "reboot.h"
+#include <linux/reboot.h>
+#include <sys/syscall.h>
#if ENABLE_FEATURE_WTMP
#include <sys/utsname.h>
@@ -109,6 +111,47 @@ static void write_wtmp(void)
#define write_wtmp() ((void)0)
#endif
+static volatile int caught_sigterm = FALSE;
+static void signal_handler(int sig)
+{
+ bb_error_msg("Caught signal %d", sig);
+
+ if (sig == SIGTERM)
+ caught_sigterm = TRUE;
+}
+
+static int reboot_with_arg(const char *arg)
+{
+ struct sigaction sa;
+ int pid;
+
+ /* Fork new thread to handle reboot */
+ if ((pid = fork()))
+ return pid < 0 ? pid : 0;
+
+ /* Handle signal and reboot in child thread */
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+ sa.sa_handler = signal_handler;
+ sigaction_set(SIGTERM, &sa);
+
+ bb_error_msg("Waiting for SIGTERM");
+
+ /* The init will send SIGTERM to us after SHUTDOWN actions */
+ while (!caught_sigterm)
+ usleep(50000);
+
+ bb_error_msg("Ready to reboot");
+
+ /* Wait 200ms for other processes to exit */
+ usleep(200000);
+ sync();
+
+ bb_error_msg("Rebooting with arg(%s)", arg);
+ return syscall(__NR_reboot, LINUX_REBOOT_MAGIC1,
+ LINUX_REBOOT_MAGIC2,
+ LINUX_REBOOT_CMD_RESTART2, arg);
+}
int halt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int halt_main(int argc UNUSED_PARAM, char **argv)
@@ -186,6 +229,11 @@ int halt_main(int argc UNUSED_PARAM, char **argv)
CONFIG_TELINIT_PATH);
}
}
+
+ /* Handle rebooting with arg */
+ if (signals[which] == SIGTERM && argc > 1 && argv[1][0] != '-')
+ rc = reboot_with_arg(argv[1]);
+
} else {
rc = reboot(magic[which]);
}
--
2.11.0

View File

@@ -0,0 +1,103 @@
From 29b6a7aa491115ef64ecd506a2945e48f09f8a56 Mon Sep 17 00:00:00 2001
From: Alistair Francis <alistair.francis@wdc.com>
Date: Tue, 19 Nov 2019 13:06:40 +0100
Subject: [PATCH] Remove stime() function calls
stime() has been deprecated in glibc 2.31 and replaced with
clock_settime(). Let's replace the stime() function calls with
clock_settime() in preperation.
function old new delta
rdate_main 197 224 +27
clock_settime - 27 +27
date_main 926 941 +15
stime 37 - -37
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 2/0 up/down: 69/-37) Total: 32 bytes
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
(cherry picked from commit d3539be8f27b8cbfdfee460fe08299158f08bcd9)
Conflicts:
coreutils/date.c
libbb/missing_syscalls.c
util-linux/rdate.c
Signed-off-by: Weiwen Chen <cww@rock-chips.com>
---
coreutils/date.c | 6 +++++-
libbb/missing_syscalls.c | 8 --------
util-linux/rdate.c | 8 ++++++--
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/coreutils/date.c b/coreutils/date.c
index 9d4a7df..0ad3a07 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -267,6 +267,9 @@ int date_main(int argc UNUSED_PARAM, char **argv)
time(&ts.tv_sec);
#endif
}
+#if !ENABLE_FEATURE_DATE_NANO
+ ts.tv_nsec = 0;
+#endif
localtime_r(&ts.tv_sec, &tm_time);
/* If date string is given, update tm_time, and maybe set date */
@@ -289,11 +292,12 @@ int date_main(int argc UNUSED_PARAM, char **argv)
if (date_str[0] != '@')
tm_time.tm_isdst = -1;
ts.tv_sec = validate_tm_time(date_str, &tm_time);
+ ts.tv_nsec = 0;
maybe_set_utc(opt);
/* if setting time, set it */
- if ((opt & OPT_SET) && stime(&ts.tv_sec) < 0) {
+ if ((opt & OPT_SET) && clock_settime(CLOCK_REALTIME, &ts) < 0) {
bb_perror_msg("can't set date");
}
}
diff --git a/libbb/missing_syscalls.c b/libbb/missing_syscalls.c
index 0934128..65709ed 100644
--- a/libbb/missing_syscalls.c
+++ b/libbb/missing_syscalls.c
@@ -16,14 +16,6 @@ pid_t getsid(pid_t pid)
return syscall(__NR_getsid, pid);
}
-int stime(const time_t *t)
-{
- struct timeval tv;
- tv.tv_sec = *t;
- tv.tv_usec = 0;
- return settimeofday(&tv, NULL);
-}
-
int sethostname(const char *name, size_t len)
{
return syscall(__NR_sethostname, name, len);
diff --git a/util-linux/rdate.c b/util-linux/rdate.c
index 960df25..b13f81d 100644
--- a/util-linux/rdate.c
+++ b/util-linux/rdate.c
@@ -97,9 +97,13 @@ int rdate_main(int argc UNUSED_PARAM, char **argv)
if (!(flags & 2)) { /* no -p (-s may be present) */
if (time(NULL) == remote_time)
bb_error_msg("current time matches remote time");
- else
- if (stime(&remote_time) < 0)
+ else {
+ struct timespec ts;
+ ts.tv_sec = remote_time;
+ ts.tv_nsec = 0;
+ if (clock_settime(CLOCK_REALTIME, &ts) < 0)
bb_perror_msg_and_die("can't set time of day");
+ }
}
if (flags != 1) /* not lone -s */
--
2.17.1

Binary file not shown.

View File

@@ -0,0 +1,12 @@
#!/bin/bash
patch -p1 < 0001-networking-libiproute-use-linux-if_packet.h-instead-.patch
patch -p1 < 0002-Makefile.flags-strip-non-l-arguments-returned-by-pkg.patch
patch -p1 < 0003-Makefile-include-per-arch-Makefile-before-Makefile.f.patch
patch -p1 < 0004-arch-sparc-sparc64-Makefile-define-ARCH_FPIC.patch
patch -p1 < 0005-httpd-fix-handling-of-range-requests.patch
patch -p1 < 0006-bunzip2-fix-runCnt-overflow-from-bug-10431.patch
patch -p1 < 0007-unlzma-fix-SEGV-closes-10436.patch
patch -p1 < 0008-busybox-support-chinese-display-in-terminal.patch
patch -p1 < 0009-halt-Support-rebooting-with-arg.patch
patch -p1 < 0010-Remove-stime-function-calls.patch

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
#!/bin/sh
# devtmpfs does not get automounted for initramfs
/bin/mount -t devtmpfs devtmpfs /dev
exec 0</dev/console
exec 1>/dev/console
exec 2>/dev/console
exec /sbin/init "$@"