This is a patch I came up with for OpenWRT
Save the following patch as 951-MIPS-ath79-add-mikrotik-serial.patch
Then copy that file into target/linux/ar71xx/patches-4.14/951-MIPS-ath79-add-mikrotik-serial.patch
Compile OpenWRT
--- a/arch/mips/ath79/mach-rbspi.c
+++ b/arch/mips/ath79/mach-rbspi.c
@@ -690,6 +690,12 @@ static __init const struct rb_info *rbsp
if (!info)
return NULL;
+ /* Set Mikrotik Serial Number */
+ if (info->board_serial) {
+ mips_set_machine_serial(info->board_serial);
+ } else
+ pr_err("Mikrotik serial number not found\n");
+
if (info->board_name) {
str = "RouterBOARD ";
if (strncmp(info->board_name, str, strlen(str))) {
--- a/arch/mips/include/asm/prom.h
+++ b/arch/mips/include/asm/prom.h
@@ -30,5 +30,7 @@ static inline void device_tree_init(void
extern char *mips_get_machine_name(void);
extern void mips_set_machine_name(const char *name);
+extern char *mips_get_machine_serial(void);
+extern void mips_set_machine_serial(char *serial);
#endif /* __ASM_PROM_H */
--- a/arch/mips/kernel/proc.c
+++ b/arch/mips/kernel/proc.c
@@ -55,6 +55,11 @@ static int show_cpuinfo(struct seq_file
if (mips_get_machine_name())
seq_printf(m, "machine\t\t\t: %s\n",
mips_get_machine_name());
+
+ /* Show manufacturer serial number */
+ if (mips_get_machine_serial())
+ seq_printf(m, "serial number\t\t: %s\n",
+ mips_get_machine_serial());
}
seq_printf(m, "processor\t\t: %ld\n", n);
--- a/arch/mips/kernel/prom.c
+++ b/arch/mips/kernel/prom.c
@@ -23,6 +23,7 @@
#include <asm/prom.h>
static char mips_machine_name[64] = "Unknown";
+char *mips_machine_serial = "None";
__init void mips_set_machine_name(const char *name)
{
@@ -38,6 +39,19 @@ char *mips_get_machine_name(void)
return mips_machine_name;
}
+__init void mips_set_machine_serial(char *serial)
+{
+ if (serial == NULL)
+ return;
+
+ mips_machine_serial = serial;
+}
+
+char *mips_get_machine_serial(void)
+{
+ return mips_machine_serial;
+}
+
#ifdef CONFIG_USE_OF
void __init early_init_dt_add_memory_arch(u64 base, u64 size)
{
--- a/arch/mips/ath79/routerboot.h
+++ b/arch/mips/ath79/routerboot.h
@@ -18,6 +18,7 @@ struct rb_info {
unsigned int soft_cfg_offs;
const char *board_name;
+ char *board_serial;
u32 hw_options;
};
--- a/arch/mips/ath79/routerboot.c
+++ b/arch/mips/ath79/routerboot.c
@@ -164,6 +164,20 @@ rb_get_board_name(void)
return tag;
}
+__init char *
+rb_get_board_serial(void)
+{
+ u16 tag_len;
+ u8 *tag;
+ int err;
+
+ err = rb_find_hard_cfg_tag(RB_ID_SERIAL_NUMBER, &tag, &tag_len);
+ if (err)
+ return NULL;
+
+ return tag;
+}
+
__init u32
rb_get_hw_options(void)
{
@@ -295,6 +309,7 @@ rb_init_info(void *data, unsigned int si
return NULL;
rb_info.board_name = rb_get_board_name();
+ rb_info.board_serial = rb_get_board_serial();
rb_info.hw_options = rb_get_hw_options();
return &rb_info;
This patch will expose the serial number in /proc/cpuinfo
root@OpenWRT:/# cat /proc/cpuinfo
system type : Qualcomm Atheros QCA9558 ver 1 rev 0
machine : MikroTik RouterBOARD 962UiGS-5HacT2HnT
serial number : 6DEC05469E1F
processor : 0
cpu model : MIPS 74Kc V5.0
BogoMIPS : 358.80
wait instruction : yes
microsecond timers : yes
tlb_entries : 32
extra interrupt vector : yes
hardware watchpoint : yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
isa : mips1 mips2 mips32r1 mips32r2
ASEs implemented : mips16 dsp dsp2
Options implemented : tlb 4kex 4k_cache prefetch mcheck ejtag llsc dc_aliases perf_cntr_intr_bit cdmm nan_legacy nan_2008 contextconfig perf
shadow register sets : 1
kscratch registers : 0
package : 0
core : 0
VCED exceptions : not available
VCEI exceptions : not available
Hope this helps!