add Black Swift board support
authorDmitriy Zherebkov <dzh@black-swift.com>
Sat, 26 Sep 2015 19:51:04 +0000 (22:51 +0300)
committerAntony Pavlov <antonynpavlov@gmail.com>
Sat, 26 Sep 2015 21:37:31 +0000 (00:37 +0300)
Black Swift is a tiny coin-sized embedded computer based on AR9331 SoC.
See http://www.black-swift.com/ for details.

See also Black Swift kickstarter page:
    https://www.kickstarter.com/projects/1133560316/black-swift-tiny-wireless-computer

Signed-off-by: Dmitriy Zherebkov <dzh@black-swift.com>
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
13 files changed:
Makefile
u-boot/Makefile
u-boot/board/ar7240/ap121/ap121.c
u-boot/common/cmd_bootm.c
u-boot/httpd/vendors/SE/404.html [new file with mode: 0644]
u-boot/httpd/vendors/SE/art.html [new file with mode: 0644]
u-boot/httpd/vendors/SE/fail.html [new file with mode: 0644]
u-boot/httpd/vendors/SE/flashing.html [new file with mode: 0644]
u-boot/httpd/vendors/SE/index.html [new file with mode: 0644]
u-boot/httpd/vendors/SE/style.css [new file with mode: 0644]
u-boot/httpd/vendors/SE/uboot.html [new file with mode: 0644]
u-boot/include/common.h
u-boot/include/configs/ap121.h

index 77f44bbe5ffc4eac92b42232b637e4128142d7f1..029b065b11f4acd19739b46f4baae1decfeb09ff 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -192,6 +192,15 @@ dragino_v2_ms14:
        @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all
        @make --no-print-directory show_size
 
+bsb:   export UBOOT_FILE_NAME=uboot_for_bsb
+bsb:   export CONFIG_MAX_UBOOT_SIZE_KB=128
+bsb:   export COMPRESSED_UBOOT=1
+bsb:   export DEVICE_VENDOR=SE
+bsb:
+       @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) bsb_config
+       @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all
+       @make --no-print-directory show_size
+
 villagetelco_mp2:      export UBOOT_FILE_NAME=uboot_for_villagetelco_mp2
 villagetelco_mp2:      export CONFIG_MAX_UBOOT_SIZE_KB=192
 villagetelco_mp2:      export DEVICE_VENDOR=villagetelco
index 5018dc7892e3c39d3c6a769fa68c7c36b64f61e0..28ab19491c21b80dc1c67fd488f3245a701d8e79 100644 (file)
@@ -492,6 +492,18 @@ gs_oolite_v1_dev_config : unconfig hornet_common_config
        
        @./mkconfig -a ap121 mips mips ap121 ar7240 ar7240
 
+bsb_config : unconfig hornet_common_config
+       @echo '======= Configuring for Black Swift board (128K compressed) at:' `date` '======='
+       @echo "#define CONFIG_FOR_BSB                       1" >> include/config.h
+       @echo "#define GPIO_SYS_LED_BIT                    27" >> include/config.h
+       @echo "#define GPIO_SYS_LED_ON                      0" >> include/config.h
+       @echo "#define GPIO_RST_BUTTON_BIT                 11" >> include/config.h
+       @echo "#define GPIO_RST_BUTTON_IS_ACTIVE_LOW        1" >> include/config.h
+       @echo "#define DEFAULT_FLASH_SIZE_IN_MB            16" >> include/config.h
+       @echo "#define BOARD_CUSTOM_STRING                  \"U-Boot for Black Swift board (AR9331)\"" >> include/config.h
+
+       @./mkconfig -a ap121 mips mips ap121 ar7240 ar7240
+
 carambola2_config : unconfig hornet_common_config
        @/bin/echo -e '\e[32m> Configuring for 8devices Carambola 2 at:' `date` '\e[0m'
        @echo "#define CONFIG_FOR_8DEVICES_CARAMBOLA2       1" >> include/config.h
index cdaec8038d29f78e255d4afd032d10becf40d6c8..b576e332f0417b0e671ac2d23eebfbfb56e133a0 100644 (file)
@@ -38,6 +38,8 @@ void led_toggle(void){
        gpio ^= 1 << GPIO_WLAN_LED_BIT;
 #elif defined(CONFIG_FOR_DRAGINO_V2) || defined(CONFIG_FOR_MESH_POTATO_V2)
        gpio ^= 1 << GPIO_WLAN_LED_BIT;
+#elif defined(CONFIG_FOR_BSB)
+       gpio ^= 1 << GPIO_SYS_LED_BIT;
 #elif defined(CONFIG_FOR_GL_INET)
        gpio ^= 1 << GPIO_WLAN_LED_BIT;
 #else
@@ -92,6 +94,8 @@ void all_led_on(void){
        SETBITVAL(gpio, GPIO_WAN_LED_BIT,      GPIO_WAN_LED_ON);
        SETBITVAL(gpio, GPIO_LAN_LED_BIT,      GPIO_LAN_LED_ON);
        SETBITVAL(gpio, GPIO_INTERNET_LED_BIT, GPIO_INTERNET_LED_ON);
+#elif defined(CONFIG_FOR_BSB)
+       SETBITVAL(gpio, GPIO_SYS_LED_BIT, GPIO_SYS_LED_ON);
 #elif defined(CONFIG_FOR_GL_INET)
        SETBITVAL(gpio, GPIO_WLAN_LED_BIT, GPIO_WLAN_LED_ON);
        SETBITVAL(gpio, GPIO_LAN_LED_BIT,  GPIO_LAN_LED_ON);
@@ -147,6 +151,8 @@ void all_led_off(void){
        SETBITVAL(gpio, GPIO_WAN_LED_BIT,      !GPIO_WAN_LED_ON);
        SETBITVAL(gpio, GPIO_LAN_LED_BIT,      !GPIO_LAN_LED_ON);
        SETBITVAL(gpio, GPIO_INTERNET_LED_BIT, !GPIO_INTERNET_LED_ON);
+#elif defined(CONFIG_FOR_BSB)
+       SETBITVAL(gpio, GPIO_SYS_LED_BIT, !GPIO_SYS_LED_ON);
 #elif defined(CONFIG_FOR_GL_INET)
        SETBITVAL(gpio, GPIO_WLAN_LED_BIT, !GPIO_WLAN_LED_ON);
        SETBITVAL(gpio, GPIO_LAN_LED_BIT,  !GPIO_LAN_LED_ON);
@@ -330,6 +336,22 @@ void gpio_config(void){
        /* set GPIO_OE */
        ar7240_reg_wr(AR7240_GPIO_OE, (ar7240_reg_rd(AR7240_GPIO_OE) | 0x10022001));
 
+#elif defined(CONFIG_FOR_BSB)
+
+       /* LED's GPIOs on Black Swift board:
+        *
+        * 27   => SYS LED (red) - output
+        * 13-17=> output only (see AR9331 datasheet)
+        * 11   => Reset switch (active low) - in (like all other by default)
+        *
+        */
+
+       // set GPIO_OE
+       ar7240_reg_wr(AR7240_GPIO_OE, (ar7240_reg_rd(AR7240_GPIO_OE) | 0x0803E000));
+
+       // turn off all
+       ar7240_reg_wr(AR7240_GPIO_SET, 0x0);
+
 #elif defined(CONFIG_FOR_DLINK_DIR505_A1)
 
        /* LED's GPIOs on DIR-505:
index 510953bbae6a330dc3d1a246b0e602e827e1ad5e..4877713d45af28fbe98b38f147dd354a064e0172 100644 (file)
@@ -74,7 +74,8 @@ ulong load_addr = CFG_LOAD_ADDR; /* default load address */
 #if !defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) && \
        !defined(CONFIG_FOR_DLINK_DIR505_A1)     && \
        !defined(CONFIG_FOR_DRAGINO_V2)          && \
-       !defined(CONFIG_FOR_MESH_POTATO_V2)
+       !defined(CONFIG_FOR_MESH_POTATO_V2)      && \
+       !defined(CONFIG_FOR_BSB)
 void fake_image_header(image_header_t *hdr, tplink_image_header_t *tpl_hdr){
        memset(hdr, 0, sizeof(image_header_t));
 
@@ -93,7 +94,7 @@ void fake_image_header(image_header_t *hdr, tplink_image_header_t *tpl_hdr){
 
        strncpy((char *)hdr->ih_name, (char *)tpl_hdr->signiture_1, IH_NMLEN);
 }
-#endif /* if !defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) && !defined(CONFIG_FOR_DLINK_DIR505_A1) && !defined(CONFIG_FOR_DRAGINO_V2) && !defined(CONFIG_FOR_MESH_POTATO_V2) */
+#endif /* if !defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) && !defined(CONFIG_FOR_DLINK_DIR505_A1) && !defined(CONFIG_FOR_DRAGINO_V2) && !defined(CONFIG_FOR_MESH_POTATO_V2) && !defined(CONFIG_FOR_BSB) */
 
 int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){
        ulong addr, data, len;
@@ -103,7 +104,8 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){
 #if !defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) && \
        !defined(CONFIG_FOR_DLINK_DIR505_A1)     && \
        !defined(CONFIG_FOR_DRAGINO_V2)          && \
-       !defined(CONFIG_FOR_MESH_POTATO_V2)
+       !defined(CONFIG_FOR_MESH_POTATO_V2)      && \
+       !defined(CONFIG_FOR_BSB)
        tplink_image_header_t *fileTag;
 #endif
 
@@ -118,7 +120,8 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){
 #if defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || \
        defined(CONFIG_FOR_DLINK_DIR505_A1)     || \
        defined(CONFIG_FOR_DRAGINO_V2)          || \
-       defined(CONFIG_FOR_MESH_POTATO_V2)
+       defined(CONFIG_FOR_MESH_POTATO_V2)      || \
+       defined(CONFIG_FOR_BSB)
        memmove(&header, (char *)addr, sizeof(image_header_t));
        print_image_hdr(hdr);
 
@@ -226,7 +229,8 @@ static void fixup_silent_linux(){
 #if defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || \
        defined(CONFIG_FOR_DLINK_DIR505_A1)     || \
        defined(CONFIG_FOR_DRAGINO_V2)          || \
-       defined(CONFIG_FOR_MESH_POTATO_V2)
+       defined(CONFIG_FOR_MESH_POTATO_V2)      || \
+       defined(CONFIG_FOR_BSB)
 static void print_type(image_header_t *hdr){
        char *os, *arch, *type, *comp;
 
@@ -403,7 +407,7 @@ void print_image_hdr(tplink_image_header_t *hdr){
        print_size(ntohl(hdr->kernelLen), "\n");
        printf("   Load address: 0x%08X\n   Entry point:  0x%08X\n\n", ntohl(hdr->kernelTextAddr), ntohl(hdr->kernelEntryPoint));
 }
-#endif /* defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || defined(CONFIG_FOR_DLINK_DIR505_A1) || defined(CONFIG_FOR_DRAGINO_V2) || defined(CONFIG_FOR_MESH_POTATO_V2) */
+#endif /* defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || defined(CONFIG_FOR_DLINK_DIR505_A1) || defined(CONFIG_FOR_DRAGINO_V2) || defined(CONFIG_FOR_MESH_POTATO_V2) || defined(CONFIG_FOR_BSB) */
 
 #if (CONFIG_COMMANDS & CFG_CMD_BOOTD)
 int do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){
diff --git a/u-boot/httpd/vendors/SE/404.html b/u-boot/httpd/vendors/SE/404.html
new file mode 100644 (file)
index 0000000..b4a2976
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML>
+<html>
+       <head>
+               <meta charset="utf-8">
+               <title>Page not found</title>
+               <link rel="stylesheet" href="style.css">
+       </head>
+       <body>
+               <div id="m">
+                       <h1 class="red">Page not found</h1>
+                       <p>The page you were looking for doesn't exist!<br>Go back to <a href="index.html">firmware update</a> page.</p>
+               </div>
+               <div id="f">This code is based on <a href="https://github.com/pepe2k/u-boot_mod" target="_blank">GitHub</a></div>
+       </body>
+</html>
\ No newline at end of file
diff --git a/u-boot/httpd/vendors/SE/art.html b/u-boot/httpd/vendors/SE/art.html
new file mode 100644 (file)
index 0000000..6cf722e
--- /dev/null
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML>
+<html>
+       <head>
+               <meta charset="utf-8">
+               <title>ART update</title>
+               <link rel="stylesheet" href="style.css">
+       </head>
+       <body>
+               <div id="m">
+                       <h1>ART UPDATE</h1>
+                       <p>You are going to update <strong>ART (Atheros Radio Test)</strong> on the device.<br>Please, choose file from your local hard drive and click <strong>Update ART</strong> button.</p>
+                       <form method="post" enctype="multipart/form-data"><input type="file" name="art"><input type="submit" value="Update ART"></form>
+                       <div class="i w">
+                               <strong>WARNINGS</strong>
+                               <ul>
+                                       <li>do not power off the device during update</li>
+                                       <li>if everything goes well, the device will restart</li>
+                                       <li>you can upload whatever you want, so be sure that you choose proper ART image for your device</li>
+                               </ul>
+                       </div>
+               </div>
+               <div id="f">This code is based on <a href="https://github.com/pepe2k/u-boot_mod" target="_blank">GitHub</a></div>
+       </body>
+</html>
\ No newline at end of file
diff --git a/u-boot/httpd/vendors/SE/fail.html b/u-boot/httpd/vendors/SE/fail.html
new file mode 100644 (file)
index 0000000..4905c66
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML>
+<html>
+       <head>
+               <meta charset="utf-8">
+               <title>Update failed</title>
+               <link rel="stylesheet" href="style.css">
+       </head>
+       <body>
+               <div id="m">
+                       <h1 class="red">Update failed!</h1>
+                       <p>Please, try again or contact with the author of this modification.<br>You can also get more information during update in U-Boot console.</p>
+               </div>
+               <div id="f">This code is based on <a href="https://github.com/pepe2k/u-boot_mod" target="_blank">GitHub</a></div>
+       </body>
+</html>
\ No newline at end of file
diff --git a/u-boot/httpd/vendors/SE/flashing.html b/u-boot/httpd/vendors/SE/flashing.html
new file mode 100644 (file)
index 0000000..9c982da
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+       <head>
+               <meta charset="utf-8">
+               <title>Update in progress</title>
+               <style>
+                       h1,p,body{margin:0;padding:0}html,body{font:13px/20px Tahoma,sans-serif;background:#135B72;color:#FFF;text-align:center;height:100%}#m{padding:30px 0}#m>*{padding:20px}#f{font-size:11px;position:absolute;bottom:0;width:100%;padding:15px 0}a{color:#FEDD12;text-decoration:none}h1{font:bold 40px/40px Arial}#l{height:30px;width:30px;margin:30px auto;-webkit-animation:r 1s infinite linear;-moz-animation:r 1s infinite linear;-o-animation:r 1s infinite linear;animation:r 1s infinite linear;border-left:5px solid #FEDD12;border-right:5px solid #FEDD12;border-bottom:5px solid #135B72;border-top:5px solid #135B72;border-radius:100%}@-webkit-keyframes r{from{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(359deg)}}@-moz-keyframes r{from{-moz-transform:rotate(0deg)}to{-moz-transform:rotate(359deg)}}@-o-keyframes r{from{-o-transform:rotate(0deg)}to{-o-transform:rotate(359deg)}}@keyframes r{from{transform:rotate(0deg)}to{transform:rotate(359deg)}}
+               </style>
+       </head>
+       <body>
+               <div id="m">
+                       <h1>Update in progress</h1>
+                       <p>Your file was successfully uploaded! Update is in progress and you should wait for automatic reset of the device.<br>Update time depends on image size and may take up to a few minutes. You can close this page.</p>
+                       <div id="l"></div>
+               </div>
+               <div id="f">This code is based on <a href="https://github.com/pepe2k/u-boot_mod" target="_blank">GitHub</a></div>
+       </body>
+</html>
\ No newline at end of file
diff --git a/u-boot/httpd/vendors/SE/index.html b/u-boot/httpd/vendors/SE/index.html
new file mode 100644 (file)
index 0000000..c8af032
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+       <head>
+               <meta charset="utf-8">
+               <title>Firmware update for Black Swift board</title>
+               <link rel="stylesheet" href="style.css">
+       </head>
+       <body>
+               <div id="h">Black Swift board</div>
+               <div id="m">
+                       <h1>Firmware update</h1>
+                       <p>You are going to upload new firmware to the device.<br>Choose a proper file from your local hard drive and click <strong>"Update firmware"</strong> button.<br>Please, do not power off the device during update, if everything goes well, the device will restart.</p>
+                       <form method="post" enctype="multipart/form-data"><input type="file" name="firmware"><input type="submit" value="Update firmware"></form>
+               </div>
+               <div id="m">Please, go <a href="uboot.html">here</a> to update U-Boot or <a href="art.html">here</a> to update ART.</div>
+               <div id="f">This code is based on <a href="https://github.com/pepe2k/u-boot_mod" target="_blank">GitHub</a></div>
+       </body>
+</html>
\ No newline at end of file
diff --git a/u-boot/httpd/vendors/SE/style.css b/u-boot/httpd/vendors/SE/style.css
new file mode 100644 (file)
index 0000000..3e21c02
--- /dev/null
@@ -0,0 +1,52 @@
+h1,
+p,
+form,
+body {
+       margin: 0;
+       padding: 0;
+}
+
+html,
+body {
+       font: 13px/20px Tahoma, sans-serif;
+       background: #135B72;
+       color: #FFF;
+       text-align: center;
+       height: 100%;
+}
+
+#m, #h {
+       padding: 30px 0;
+}
+
+#h {
+       font: bold 40px/40px Arial;
+       background: #ffffff;
+       color: #000000;
+       text-align: center;
+}
+
+#m > * {
+       padding: 20px;
+}
+
+#f {
+       font-size: 11px;
+       position: absolute;
+       bottom: 0;
+       width: 100%;
+       padding: 15px 0;
+}
+
+a {
+       color: #FEDD12;
+       text-decoration: none;
+}
+
+h1 {
+       font: bold 40px/40px Arial;
+}
+
+.red {
+       color: #ED0000;
+}
\ No newline at end of file
diff --git a/u-boot/httpd/vendors/SE/uboot.html b/u-boot/httpd/vendors/SE/uboot.html
new file mode 100644 (file)
index 0000000..26d3f24
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML>
+<html>
+       <head>
+               <meta charset="utf-8">
+               <title>U-Boot update</title>
+               <link rel="stylesheet" href="style.css">
+       </head>
+       <body>
+               <div id="m">
+                       <h1>U-BOOT UPDATE</h1>
+                       <p>You are going to update <strong>U-Boot bootloader</strong> on the device.<br>Please, choose file from your local hard drive and click <strong>Update U-Boot</strong> button.</p>
+                       <form method="post" enctype="multipart/form-data"><input type="file" name="uboot"><input type="submit" value="Update U-Boot"></form>
+                       <div class="i w">
+                               <strong>WARNINGS</strong>
+                               <ul>
+                                       <li>do not power off the device during update</li>
+                                       <li>if everything goes well, the device will restart</li>
+                                       <li>you can upload whatever you want, so be sure that you choose proper U-Boot image for your device</li>
+                                       <li>updating U-Boot is a very dangerous operation and may damage your device!</li>
+                               </ul>
+                       </div>
+               </div>
+               <div id="f">This code is based on <a href="https://github.com/pepe2k/u-boot_mod" target="_blank">GitHub</a></div>
+       </body>
+</html>
\ No newline at end of file
index 06eed3f0b97cde3e9fd3ac07bf030a474b8e7d34..8c818f1c6c550381334f39ff8d285054f38a0b44 100644 (file)
@@ -195,6 +195,7 @@ int autoscript (ulong addr);
  * use different (simply) image header
  */
 #if !defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) && \
+       !defined(CONFIG_FOR_BSB)     && \
        !defined(CONFIG_FOR_DLINK_DIR505_A1)     && \
        !defined(CONFIG_FOR_DRAGINO_V2)          && \
        !defined(CONFIG_FOR_MESH_POTATO_V2)
@@ -203,6 +204,7 @@ int autoscript (ulong addr);
 
 /* common/cmd_bootm.c */
 #if defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || \
+       defined(CONFIG_FOR_BSB)     || \
        defined(CONFIG_FOR_DLINK_DIR505_A1)     || \
        defined(CONFIG_FOR_DRAGINO_V2)          || \
        defined(CONFIG_FOR_MESH_POTATO_V2)
index 69392195585bd43c387d261fd011cc9841828b06..982cb7b00bd06ab028afa37d9a74d276f1737585 100644 (file)
 
        #define CONFIG_BOOTARGS "console=ttyS0,115200 root=31:02 rootfstype=squashfs init=/sbin/init mtdparts=ar7240-nor0:128k(u-boot),1024k(kernel),2816k(rootfs),64k(config),64k(ART)"
 
+#elif defined(CONFIG_FOR_BSB)
+
+       #define CONFIG_BOOTARGS "console=ttyS0,115200 root=31:02 rootfstype=squashfs init=/sbin/init mtdparts=ar7240-nor0:128k(u-boot),64k(u-boot-env),16128k(firmware),64k(ART)"
+
 #elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2)
 
        #define CONFIG_BOOTARGS "console=ttyS0,115200 root=31:02 rootfstype=squashfs init=/sbin/init mtdparts=ar7240-nor0:256k(u-boot),64k(u-boot-env),16000k(firmware),64k(ART)"
@@ -88,6 +92,9 @@
       defined(CONFIG_FOR_MESH_POTATO_V2)
        #define CFG_LOAD_ADDR                    0x9F040000
        #define UPDATE_SCRIPT_FW_ADDR   "0x9F040000"
+#elif defined(CONFIG_FOR_BSB)
+       #define CFG_LOAD_ADDR                    0x9F030000
+       #define UPDATE_SCRIPT_FW_ADDR   "0x9F030000"
 #else
        #define CFG_LOAD_ADDR                    0x9F020000
        #define UPDATE_SCRIPT_FW_ADDR   "0x9F020000"
 #elif defined(CONFIG_FOR_DRAGINO_V2) || \
       defined(CONFIG_FOR_MESH_POTATO_V2)
        #define CONFIG_BOOTCOMMAND "bootm 0x9F040000"
+#elif defined(CONFIG_FOR_BSB)
+       #define CONFIG_BOOTCOMMAND "bootm 0x9F030000"
 #else
        #define CONFIG_BOOTCOMMAND "bootm 0x9F020000"
 #endif
        #define CFG_PROMPT "dr_boot> "
 #endif
 
+#if defined(CONFIG_FOR_BSB)
+       #if defined(CFG_PROMPT)
+               #undef CFG_PROMPT
+       #endif
+       #define CFG_PROMPT "BSB> "
+#endif
+
 #undef CFG_HZ
 #define        CFG_HZ                          bd->bi_cfg_hz
 #undef CPU_PLL_CONFIG_VAL
        #define CFG_ENV_ADDR            0x9F040000
        #define CFG_ENV_SIZE            0x8000
        #define CFG_ENV_SECT_SIZE       0x10000
+#elif defined(CONFIG_FOR_BSB)
+       #define CFG_ENV_ADDR            0x9F020000
+       #define CFG_ENV_SIZE            0x8000
+       #define CFG_ENV_SECT_SIZE       0x10000
 #else
        #define CFG_ENV_ADDR            0x9F01EC00
        #define CFG_ENV_SIZE            0x1000
 
 #elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || \
       defined(CONFIG_FOR_DRAGINO_V2) || \
-      defined(CONFIG_FOR_MESH_POTATO_V2)
+      defined(CONFIG_FOR_MESH_POTATO_V2) || \
+      defined(CONFIG_FOR_BSB)
 
        #define CONFIG_COMMANDS (CFG_CMD_MEMORY | \
                                                         CFG_CMD_DHCP   | \
       defined(CONFIG_FOR_MESH_POTATO_V2)
        #define UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES                       "0x30000"
        #define UPDATE_SCRIPT_UBOOT_BACKUP_SIZE_IN_BYTES        UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES
+#elif defined(CONFIG_FOR_BSB)
+       #define UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES                       "0x20000"
+       #define UPDATE_SCRIPT_UBOOT_BACKUP_SIZE_IN_BYTES        UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES
 #else
        // TODO: should be == CONFIG_MAX_UBOOT_SIZE_KB
        #define UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES                       "0x1EC00"
 #elif defined(CONFIG_FOR_DRAGINO_V2) || \
       defined(CONFIG_FOR_MESH_POTATO_V2)
        #define WEBFAILSAFE_UPLOAD_KERNEL_ADDRESS                       WEBFAILSAFE_UPLOAD_UBOOT_ADDRESS + 0x40000
+#elif defined(CONFIG_FOR_BSB)
+       #define WEBFAILSAFE_UPLOAD_KERNEL_ADDRESS                       WEBFAILSAFE_UPLOAD_UBOOT_ADDRESS + 0x30000
 #else
        #define WEBFAILSAFE_UPLOAD_KERNEL_ADDRESS                       WEBFAILSAFE_UPLOAD_UBOOT_ADDRESS + 0x20000
 #endif
 #elif defined(CONFIG_FOR_GS_OOLITE_V1_DEV)
        // GS-Oolite v1: 128k(U-Boot + MAC),64k(ART)
        #define WEBFAILSAFE_UPLOAD_LIMITED_AREA_IN_BYTES        (192 * 1024)
+#elif defined(CONFIG_FOR_BSB)
+       // Black Swift board: 128k(U-Boot),64k(U-Boot env),64k(ART)
+       #define WEBFAILSAFE_UPLOAD_LIMITED_AREA_IN_BYTES        (256 * 1024)
 #else
        // TP-Link: 64k(U-Boot),64k(MAC/model/WPS pin block),64k(ART)
        #define WEBFAILSAFE_UPLOAD_LIMITED_AREA_IN_BYTES        (192 * 1024)
        #define OFFSET_MAC_DATA_BLOCK                   0x010000
        #define OFFSET_MAC_DATA_BLOCK_LENGTH    0x010000
        #define OFFSET_MAC_ADDRESS                              0x00FC00
+#elif defined(CONFIG_FOR_BSB)
+       // Black Swift board has only one MAC address at the beginning of ART partition
+       #define OFFSET_MAC_DATA_BLOCK           0xFF0000
+       #define OFFSET_MAC_DATA_BLOCK_LENGTH    0x010000
+       #define OFFSET_MAC_ADDRESS              0x000000
 #else
        #define OFFSET_MAC_DATA_BLOCK                   0x010000
        #define OFFSET_MAC_DATA_BLOCK_LENGTH    0x010000
        !defined(CONFIG_FOR_GS_OOLITE_V1_DEV)    && \
        !defined(CONFIG_FOR_DRAGINO_V2)          && \
        !defined(CONFIG_FOR_MESH_POTATO_V2)      && \
-       !defined(CONFIG_FOR_GL_INET)
+       !defined(CONFIG_FOR_GL_INET)             && \
+       !defined(CONFIG_FOR_BSB)
 #define OFFSET_ROUTER_MODEL                                    0x00FD00
 #endif
 
        #define PLL_IN_FLASH_DATA_BLOCK_OFFSET  0x00030000
        #define PLL_IN_FLASH_DATA_BLOCK_LENGTH  0x00010000
        #define PLL_IN_FLASH_MAGIC_OFFSET               0x0000FFF0      // last 16 bytes
+#elif defined(CONFIG_FOR_BSB)
+       /*
+        * We will store PLL and CLOCK registers
+        * configuration at the end of environment
+        * sector (64 KB, environment uses only half!)
+        */
+       #define PLL_IN_FLASH_MAGIC                              0x504C4C73
+       #define PLL_IN_FLASH_DATA_BLOCK_OFFSET  0x00020000
+       #define PLL_IN_FLASH_DATA_BLOCK_LENGTH  0x00010000
+       #define PLL_IN_FLASH_MAGIC_OFFSET               0x0000FFF0      // last 16 bytes
 #else
        /*
         * All TP-Link routers have a lot of unused space