Problem with building kernel for a new device with MT7628 chipset

I want to add support for Keenetic Buddy 4 (KN-3211) to OpenWrt. This router (actually a retransmitter) has a MT76x8 SoC and is similar to already supported KN-1613 Explorer/Air (image for KN-1613 works on KN-3211, with exception for LEDs and buttons).

So when I'm trying to build OpenWrt for this device (here is patch), make outputs the following lines:

board.c:48:2: error: #error "Unsupported SOC..."                                         
   48 | #error "Unsupported SOC..."                                                      
      |  ^~~~~                                                                           
board.c: In function 'board_putc':                                                       
board.c:62:25: error: 'UART_LSR' undeclared (first use in this function); did you mean 'UART_LSR_THRE'?
   62 |         while ((READREG(UART_LSR) & UART_LSR_MASK) == 0);                        
      |                         ^~~~~~~~                                                 
board.c:52:57: note: in definition of macro 'READREG'                                    
   52 | #define READREG(r)              (*(volatile uint32_t *)(r))                      
      |                                                         ^                        
board.c:62:25: note: each undeclared identifier is reported only once for each function it appears in
   62 |         while ((READREG(UART_LSR) & UART_LSR_MASK) == 0);                        
      |                         ^~~~~~~~                                                 
board.c:52:57: note: in definition of macro 'READREG'                                    
   52 | #define READREG(r)              (*(volatile uint32_t *)(r))                      
      |                                                         ^                        
board.c:62:37: error: 'UART_LSR_MASK' undeclared (first use in this function); did you mean 'UART_LSR_THRE'?
   62 |         while ((READREG(UART_LSR) & UART_LSR_MASK) == 0);                        
      |                                     ^~~~~~~~~~~~~                                
      |                                     UART_LSR_THRE                                
board.c:63:18: error: 'UART_THR' undeclared (first use in this function); did you mean 'UART_LSR_THRE'?
   63 |         WRITEREG(UART_THR, ch);                                                  
      |                  ^~~~~~~~                                                        
board.c:53:49: note: in definition of macro 'WRITEREG'                                   
   53 | #define WRITEREG(r,v)   (*(volatile uint32_t *)(r)) = v                          
      |                                                 ^                                
make[7]: *** [Makefile:107: board.o] Error 1                                             
make[7]: Leaving directory '/home/lotigara/openwrt/build_dir/target-mipsel_24kc_musl/linux-ramips_mt76x8/tmp/openwrt-ramips-mt76x8-keenetic_kn-3211-initramfs-kernel.bin.src'
make[6]: *** [Makefile:43: loader-compile] Error 2                                       
make[6]: Leaving directory '/home/lotigara/openwrt/target/linux/ramips/image/lzma-loader'

Piece of $HOME/openwrt/build_dir/target-mipsel_24kc_musl/linux-ramips_mt76x8/tmp/openwrt-ramips-mt76x8-keenetic_kn-3211-initramfs-kernel.bin.src/board.c:

#if defined(SOC_MT7620) || defined(SOC_RT3883)
#define UART_BASE                       KSEG1ADDR(0x10000c00)
#define UART_THR                        (UART_BASE + 0x04)
#define UART_LSR                        (UART_BASE + 0x1c)
#define UART_LSR_MASK                   UART_LSR_TEMT
#elif defined(SOC_MT7621)
#define UART_BASE                       KSEG1ADDR(0x1e000c00)
#define UART_THR                        (UART_BASE + 0x00)
#define UART_LSR                        (UART_BASE + 0x14)
#define UART_LSR_MASK                   UART_LSR_THRE
#elif defined(SOC_RT305X)
#define UART_BASE                       KSEG1ADDR(0x10000c00)
#define UART_THR                        (UART_BASE + 0x04)
#define UART_LSR                        (UART_BASE + 0x1c)
#define UART_LSR_MASK                   UART_LSR_THRE
#else
#error "Unsupported SOC..."
#endif

There is no check for SOC_MT76X8 (or SOC_MT7628).

I would appreciate any help!

You need to add defines before line 48 of board.c

Where could I take them from? And what board.c needs to be modified? (target/linux/ramips/image/lzma-loader/src/board.c)

The problem was in the Makefile. There were some lines starting with @ character, I deleted them and now I have an OpenWrt Wi-Fi repeater!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.