diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/BoardModel.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/BoardModel.java index b4aff9cb..435edc8a 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/BoardModel.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/BoardModel.java @@ -24,151 +24,151 @@ */ public enum BoardModel { MODEL_1_A("Raspberry Pi 1 Model A", SINGLE_BOARD_COMPUTER, - new ArrayList<>(), - PiModel.MODEL_A, - HeaderVersion.TYPE_1, - LocalDate.of(2013, 2, 1), - Soc.BCM2835, - Cpu.ARM1176JZF_S, 1, - Collections.singletonList(700), - Collections.singletonList(256 * 1024)), + new ArrayList<>(), + PiModel.MODEL_A, + HeaderVersion.TYPE_1, + LocalDate.of(2013, 2, 1), + Soc.BCM2835, + Cpu.ARM1176JZF_S, 1, + Collections.singletonList(700), + Collections.singletonList(256 * 1024)), MODEL_1_A_PLUS("Raspberry Pi 1 Model A+", SINGLE_BOARD_COMPUTER, - Collections.singletonList("900021"), - PiModel.MODEL_A, - HeaderVersion.TYPE_1, - LocalDate.of(2014, 11, 1), - Soc.BCM2835, - Cpu.ARM1176JZF_S, 1, - Collections.singletonList(700), - Arrays.asList(256 * 1024, 512 * 1024), - Collections.singletonList("Amount of memory changed to 512Mb on 20160810")), + Collections.singletonList("900021"), + PiModel.MODEL_A, + HeaderVersion.TYPE_1, + LocalDate.of(2014, 11, 1), + Soc.BCM2835, + Cpu.ARM1176JZF_S, 1, + Collections.singletonList(700), + Arrays.asList(256 * 1024, 512 * 1024), + Collections.singletonList("Amount of memory changed to 512Mb on 20160810")), MODEL_3_A_PLUS("Raspberry Pi 3 Model A+", SINGLE_BOARD_COMPUTER, - Collections.singletonList("9020e0"), - PiModel.MODEL_A, - HeaderVersion.TYPE_3, - LocalDate.of(2018, 11, 1), - Soc.BCM2837B0, - Cpu.CORTEX_A53, 4, - Collections.singletonList(1400), - Collections.singletonList(512 * 1024)), + Arrays.asList("9020e0", "9020e1"), + PiModel.MODEL_A, + HeaderVersion.TYPE_3, + LocalDate.of(2018, 11, 1), + Soc.BCM2837B0, + Cpu.CORTEX_A53, 4, + Collections.singletonList(1400), + Collections.singletonList(512 * 1024)), MODEL_1_B("Raspberry Pi 1 Model B", SINGLE_BOARD_COMPUTER, - new ArrayList<>(), - PiModel.MODEL_B, - HeaderVersion.TYPE_1, - LocalDate.of(2012, 4, 1), - Soc.BCM2835, - Cpu.ARM1176JZF_S, 1, - Collections.singletonList(700), - Arrays.asList(256 * 1024, 512 * 1024), - Collections.singletonList("Amount of memory changed to 512Mb on 20121015")), + new ArrayList<>(), + PiModel.MODEL_B, + HeaderVersion.TYPE_1, + LocalDate.of(2012, 4, 1), + Soc.BCM2835, + Cpu.ARM1176JZF_S, 1, + Collections.singletonList(700), + Arrays.asList(256 * 1024, 512 * 1024), + Collections.singletonList("Amount of memory changed to 512Mb on 20121015")), MODEL_1_B_PLUS("Raspberry Pi 1 Model B+", SINGLE_BOARD_COMPUTER, - Collections.singletonList("900032"), - PiModel.MODEL_B, - HeaderVersion.TYPE_1, - LocalDate.of(2014, 7, 1), - Soc.BCM2835, - Cpu.ARM1176JZF_S, 1, - Collections.singletonList(700), - Collections.singletonList(512 * 1024)), + Collections.singletonList("900032"), + PiModel.MODEL_B, + HeaderVersion.TYPE_1, + LocalDate.of(2014, 7, 1), + Soc.BCM2835, + Cpu.ARM1176JZF_S, 1, + Collections.singletonList(700), + Collections.singletonList(512 * 1024)), MODEL_2_B("Raspberry Pi 2 Model B", SINGLE_BOARD_COMPUTER, - Arrays.asList("a01040", "a01041", "a21041"), - PiModel.MODEL_B, - HeaderVersion.TYPE_2, - LocalDate.of(2015, 2, 1), - Soc.BCM2836, - Cpu.CORTEX_A7, 4, - Collections.singletonList(900), - Collections.singletonList(1024 * 1024)), + Arrays.asList("a01040", "a01041", "a21041"), + PiModel.MODEL_B, + HeaderVersion.TYPE_2, + LocalDate.of(2015, 2, 1), + Soc.BCM2836, + Cpu.CORTEX_A7, 4, + Collections.singletonList(900), + Collections.singletonList(1024 * 1024)), MODEL_2_B_V1_2("Raspberry Pi 2 Model B V1.2", SINGLE_BOARD_COMPUTER, - Arrays.asList("a02042", "a22042"), - PiModel.MODEL_B, - HeaderVersion.TYPE_2, - LocalDate.of(2016, 10, 1), - Soc.BCM2837, - Cpu.CORTEX_A53, 4, - Collections.singletonList(900), - Collections.singletonList(1024 * 1024)), + Arrays.asList("a02042", "a22042"), + PiModel.MODEL_B, + HeaderVersion.TYPE_2, + LocalDate.of(2016, 10, 1), + Soc.BCM2837, + Cpu.CORTEX_A53, 4, + Collections.singletonList(900), + Collections.singletonList(1024 * 1024)), MODEL_3_B("Raspberry Pi 3 Model B", SINGLE_BOARD_COMPUTER, - Arrays.asList("a02082", "a22082", "a32082", "a52082", "a22083"), - PiModel.MODEL_B, - HeaderVersion.TYPE_3, - LocalDate.of(2016, 2, 1), - Soc.BCM2837, - Cpu.CORTEX_A53, 4, - Collections.singletonList(1200), - Collections.singletonList(1024 * 1024)), + Arrays.asList("a02082", "a22082", "a32082", "a52082", "a22083"), + PiModel.MODEL_B, + HeaderVersion.TYPE_3, + LocalDate.of(2016, 2, 1), + Soc.BCM2837, + Cpu.CORTEX_A53, 4, + Collections.singletonList(1200), + Collections.singletonList(1024 * 1024)), MODEL_3_B_PLUS("Raspberry Pi 3 Model B+", SINGLE_BOARD_COMPUTER, - Collections.singletonList("a020d3"), - PiModel.MODEL_B, - HeaderVersion.TYPE_3, - LocalDate.of(2018, 3, 14), - Soc.BCM2837B0, - Cpu.CORTEX_A53, 4, - Collections.singletonList(1400), - Collections.singletonList(1024 * 1024)), + Arrays.asList("a020d3", "a020d4"), + PiModel.MODEL_B, + HeaderVersion.TYPE_3, + LocalDate.of(2018, 3, 14), + Soc.BCM2837B0, + Cpu.CORTEX_A53, 4, + Collections.singletonList(1400), + Collections.singletonList(1024 * 1024)), MODEL_4_B("Raspberry Pi 4 Model B", SINGLE_BOARD_COMPUTER, - Arrays.asList("a03111", "b03111", "b03112", "b03114", "b03115", "c03111", "c03112", "c03114", "c03115", "d03114", "d03115"), - PiModel.MODEL_B, - HeaderVersion.TYPE_3, - LocalDate.of(2019, 6, 24), - Soc.BCM2711, - Cpu.CORTEX_A72, 4, - Arrays.asList(1500, 1800), - Arrays.asList(1024 * 1024, 2048 * 1024, 4096 * 1024, 8192 * 1024)), + Arrays.asList("a03111", "b03111", "b03112", "b03114", "b03115", "c03111", "c03112", "c03114", "c03115", "d03114", "d03115"), + PiModel.MODEL_B, + HeaderVersion.TYPE_3, + LocalDate.of(2019, 6, 24), + Soc.BCM2711, + Cpu.CORTEX_A72, 4, + Arrays.asList(1500, 1800), + Arrays.asList(1024 * 1024, 2048 * 1024, 4096 * 1024, 8192 * 1024)), MODEL_400("Raspberry Pi 400", ALL_IN_ONE_COMPUTER, - Collections.singletonList("c03130"), - PiModel.MODEL_B, - HeaderVersion.TYPE_3, - LocalDate.of(2020, 11, 2), - Soc.BCM2711C0, - Cpu.CORTEX_A72, 4, - Collections.singletonList(1800), - Collections.singletonList(4096 * 1024)), + Collections.singletonList("c03130"), + PiModel.MODEL_B, + HeaderVersion.TYPE_3, + LocalDate.of(2020, 11, 2), + Soc.BCM2711C0, + Cpu.CORTEX_A72, 4, + Collections.singletonList(1800), + Collections.singletonList(4096 * 1024)), MODEL_5_B("Raspberry Pi 5 Model B", SINGLE_BOARD_COMPUTER, - Arrays.asList("b04170", "c04170", "d04170"), - PiModel.MODEL_B, - HeaderVersion.TYPE_3, - LocalDate.of(2023, 9, 28), - Soc.BCM2712, - Cpu.CORTEX_A76, 4, - Collections.singletonList(2400), - Arrays.asList(2048 * 1024, 4096 * 1024, 8192 * 1024)), + Arrays.asList("b04170", "c04170", "d04170"), + PiModel.MODEL_B, + HeaderVersion.TYPE_3, + LocalDate.of(2023, 9, 28), + Soc.BCM2712, + Cpu.CORTEX_A76, 4, + Collections.singletonList(2400), + Arrays.asList(2048 * 1024, 4096 * 1024, 8192 * 1024)), COMPUTE_1("Compute Module 1", STACK_ON_COMPUTER, - Collections.singletonList("900061"), - PiModel.COMPUTE, - HeaderVersion.COMPUTE, - LocalDate.of(2014, 4, 1), - Soc.BCM2835, - Cpu.ARM1176JZF_S, 1, - Collections.singletonList(700), - Collections.singletonList(512 * 1024)), + Collections.singletonList("900061"), + PiModel.COMPUTE, + HeaderVersion.COMPUTE, + LocalDate.of(2014, 4, 1), + Soc.BCM2835, + Cpu.ARM1176JZF_S, 1, + Collections.singletonList(700), + Collections.singletonList(512 * 1024)), COMPUTE_3("Compute Module 3", STACK_ON_COMPUTER, - Arrays.asList("a020a0", "a220a0"), - PiModel.COMPUTE, - HeaderVersion.COMPUTE, - LocalDate.of(2017, 1, 1), - Soc.BCM2837, - Cpu.CORTEX_A53, 4, - Collections.singletonList(1200), - Collections.singletonList(1024 * 1024)), + Arrays.asList("a020a0", "a220a0"), + PiModel.COMPUTE, + HeaderVersion.COMPUTE, + LocalDate.of(2017, 1, 1), + Soc.BCM2837, + Cpu.CORTEX_A53, 4, + Collections.singletonList(1200), + Collections.singletonList(1024 * 1024)), COMPUTE_3_PLUS("Compute Module 3+", STACK_ON_COMPUTER, - Collections.singletonList("a02100"), - PiModel.COMPUTE, - HeaderVersion.COMPUTE, - LocalDate.of(2019, 1, 1), - Soc.BCM2837B0, - Cpu.CORTEX_A53, 4, - Collections.singletonList(1200), - Collections.singletonList(1024 * 1024)), + Collections.singletonList("a02100"), + PiModel.COMPUTE, + HeaderVersion.COMPUTE, + LocalDate.of(2019, 1, 1), + Soc.BCM2837B0, + Cpu.CORTEX_A53, 4, + Collections.singletonList(1200), + Collections.singletonList(1024 * 1024)), COMPUTE_4("Compute Module 4", STACK_ON_COMPUTER, - Arrays.asList("a03140", "b03140", "c03140", "d03140"), - PiModel.COMPUTE, - HeaderVersion.COMPUTE, - LocalDate.of(2020, 10, 1), - Soc.BCM2711, - Cpu.CORTEX_A72, 4, - Collections.singletonList(1500), - Arrays.asList(1024 * 1024, 2048 * 1024, 4096 * 1024, 8192 * 1024)), + Arrays.asList("a03140", "b03140", "c03140", "d03140", "a03141", "b03141", "c03141", "d03141"), + PiModel.COMPUTE, + HeaderVersion.COMPUTE, + LocalDate.of(2020, 10, 1), + Soc.BCM2711, + Cpu.CORTEX_A72, 4, + Collections.singletonList(1500), + Arrays.asList(1024 * 1024, 2048 * 1024, 4096 * 1024, 8192 * 1024)), // https://datasheets.raspberrypi.com/cm4s/cm4s-datasheet.pdf COMPUTE_4_SODIMM("Compute Module 4 SODIMM", STACK_ON_COMPUTER, new ArrayList<>(), // Not known yet @@ -180,87 +180,87 @@ public enum BoardModel { Collections.singletonList(1500), Arrays.asList(1024 * 1024, 2048 * 1024, 4096 * 1024, 8192 * 1024)), ZERO_PCB_1_2("Raspberry Pi Zero PCB V1.2", SINGLE_BOARD_COMPUTER, - Arrays.asList("900092", "920092"), - PiModel.ZERO, - HeaderVersion.TYPE_3, - LocalDate.of(2015, 11, 1), - Soc.BCM2835, - Cpu.ARM1176JZF_S, 1, - Collections.singletonList(1000), - Collections.singletonList(512 * 1024)), + Arrays.asList("900092", "920092"), + PiModel.ZERO, + HeaderVersion.TYPE_3, + LocalDate.of(2015, 11, 1), + Soc.BCM2835, + Cpu.ARM1176JZF_S, 1, + Collections.singletonList(1000), + Collections.singletonList(512 * 1024)), ZERO_PCB_1_3("Raspberry Pi Zero PCB V1.3", SINGLE_BOARD_COMPUTER, - Arrays.asList("900093", "920093"), - PiModel.ZERO, - HeaderVersion.TYPE_3, - LocalDate.of(2016, 5, 1), - Soc.BCM2835, - Cpu.ARM1176JZF_S, 1, - Collections.singletonList(1000), - Collections.singletonList(512 * 1024)), + Arrays.asList("900093", "920093"), + PiModel.ZERO, + HeaderVersion.TYPE_3, + LocalDate.of(2016, 5, 1), + Soc.BCM2835, + Cpu.ARM1176JZF_S, 1, + Collections.singletonList(1000), + Collections.singletonList(512 * 1024)), ZERO_W("Raspberry Pi Zero W", SINGLE_BOARD_COMPUTER, - Collections.singletonList("9000c1"), - PiModel.ZERO, - HeaderVersion.TYPE_3, - LocalDate.of(2017, 2, 28), - Soc.BCM2835, - Cpu.ARM1176JZF_S, 1, - Collections.singletonList(1000), - Collections.singletonList(512 * 1024)), + Collections.singletonList("9000c1"), + PiModel.ZERO, + HeaderVersion.TYPE_3, + LocalDate.of(2017, 2, 28), + Soc.BCM2835, + Cpu.ARM1176JZF_S, 1, + Collections.singletonList(1000), + Collections.singletonList(512 * 1024)), ZERO_V2("Raspberry Pi Zero V2", SINGLE_BOARD_COMPUTER, - Collections.singletonList("902120"), - PiModel.ZERO, - HeaderVersion.TYPE_3, - LocalDate.of(2021, 10, 28), - Soc.BCM2710A1, - Cpu.CORTEX_A53, 4, - Collections.singletonList(1000), - Collections.singletonList(512 * 1024)), + Collections.singletonList("902120"), + PiModel.ZERO, + HeaderVersion.TYPE_3, + LocalDate.of(2021, 10, 28), + Soc.BCM2710A1, + Cpu.CORTEX_A53, 4, + Collections.singletonList(1000), + Collections.singletonList(512 * 1024)), PICO("Raspberry Pi Pico", MICROCONTROLLER, - new ArrayList<>(), - PiModel.PICO, - HeaderVersion.PICO, - LocalDate.of(2021, 1, 1), - Soc.RP2040, - Cpu.CORTEX_MO_PLUS, 1, - Collections.singletonList(133), - Collections.singletonList(264 + 2048)), + new ArrayList<>(), + PiModel.PICO, + HeaderVersion.PICO, + LocalDate.of(2021, 1, 1), + Soc.RP2040, + Cpu.CORTEX_MO_PLUS, 1, + Collections.singletonList(133), + Collections.singletonList(264 + 2048)), PICO_W("Raspberry Pi Pico W", MICROCONTROLLER, - new ArrayList<>(), - PiModel.PICO, - HeaderVersion.PICO, - LocalDate.of(2022, 6, 1), - Soc.RP2040, - Cpu.CORTEX_MO_PLUS, 1, - Collections.singletonList(133), - Collections.singletonList(264 + 2048), - Collections.singletonList("Same form factor as PICO but with Wi-Fi")), + new ArrayList<>(), + PiModel.PICO, + HeaderVersion.PICO, + LocalDate.of(2022, 6, 1), + Soc.RP2040, + Cpu.CORTEX_MO_PLUS, 1, + Collections.singletonList(133), + Collections.singletonList(264 + 2048), + Collections.singletonList("Same form factor as PICO but with Wi-Fi")), PICO_2("Raspberry Pi Pico 2", MICROCONTROLLER, - new ArrayList<>(), - PiModel.PICO, - HeaderVersion.PICO, - LocalDate.of(2024, 8, 8), - Soc.RP2350, - Cpu.CORTEX_M33, 1, - Collections.singletonList(150), - Collections.singletonList(520 + 4096)), + new ArrayList<>(), + PiModel.PICO, + HeaderVersion.PICO, + LocalDate.of(2024, 8, 8), + Soc.RP2350, + Cpu.CORTEX_M33, 1, + Collections.singletonList(150), + Collections.singletonList(520 + 4096)), PICO_2_W("Raspberry Pi Pico 2 W", MICROCONTROLLER, - new ArrayList<>(), - PiModel.PICO, - HeaderVersion.PICO, - LocalDate.of(2024, 8, 8), - Soc.RP2350, - Cpu.CORTEX_M33, 1, - Collections.singletonList(150), - Collections.singletonList(520 + 4096)), + new ArrayList<>(), + PiModel.PICO, + HeaderVersion.PICO, + LocalDate.of(2024, 8, 8), + Soc.RP2350, + Cpu.CORTEX_M33, 1, + Collections.singletonList(150), + Collections.singletonList(520 + 4096)), UNKNOWN("Unknown", BoardType.UNKNOWN, - new ArrayList<>(), - PiModel.UNKNOWN, - HeaderVersion.UNKNOWN, - null, - Soc.UNKNOWN, - Cpu.UNKNOWN, 0, - new ArrayList<>(), - new ArrayList<>()); + new ArrayList<>(), + PiModel.UNKNOWN, + HeaderVersion.UNKNOWN, + null, + Soc.UNKNOWN, + Cpu.UNKNOWN, 0, + new ArrayList<>(), + new ArrayList<>()); private static final Logger logger = LoggerFactory.getLogger(BoardModel.class); @@ -282,7 +282,7 @@ public enum BoardModel { Soc soc, Cpu cpu, Integer numberOfCpu, List versionsProcessorSpeedInMhz, List versionsMemoryInKb) { this(label, boardType, boardCodes, model, headerVersion, releaseDate, soc, cpu, numberOfCpu, versionsProcessorSpeedInMhz, - versionsMemoryInKb, new ArrayList<>()); + versionsMemoryInKb, new ArrayList<>()); } BoardModel(String label, BoardType boardType, List boardCodes, @@ -304,22 +304,22 @@ public enum BoardModel { this.remarks = remarks; } - public static BoardModel getByBoardCode(String boardCode) { + public static BoardModel getByBoardCode(String boardCode) throws Exception { var matches = Arrays.stream(BoardModel.values()) - .filter(bm -> bm.boardCodes.contains(boardCode)) - .collect(Collectors.toList()); + .filter(bm -> bm.boardCodes.contains(boardCode)) + .collect(Collectors.toList()); if (matches.isEmpty()) { return BoardModel.UNKNOWN; } else if (matches.size() > 1) { - logger.error("Too many matching models found for code {}, probably an error in the definitions", boardCode); + throw (new Exception("Too many matching models found for code " + boardCode + ", probably an error in the definitions")); } return matches.get(0); } public static BoardModel getByBoardName(String boardName) { var matches = Arrays.stream(BoardModel.values()) - .filter(bm -> boardName.toLowerCase().startsWith(bm.label.toLowerCase())) - .collect(Collectors.toList()); + .filter(bm -> boardName.toLowerCase().startsWith(bm.label.toLowerCase())) + .collect(Collectors.toList()); if (matches.isEmpty()) { return BoardModel.UNKNOWN; } else if (matches.size() > 1) { @@ -328,6 +328,13 @@ public static BoardModel getByBoardName(String boardName) { return matches.get(0); } + public static List getAllBoardCodes() { + return Arrays.stream(BoardModel.values()) + .map(b -> b.boardCodes) + .flatMap(List::stream) // Flatten the nested lists into a single stream + .collect(Collectors.toList()); // Collect elements into one list + } + public String getName() { return name(); } diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/util/BoardInfoHelper.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/util/BoardInfoHelper.java index 0aa1065a..44cec70b 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/util/BoardInfoHelper.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/util/BoardInfoHelper.java @@ -13,7 +13,7 @@ public class BoardInfoHelper { private static final Logger logger = LoggerFactory.getLogger(BoardInfoHelper.class); private static final BoardInfoHelper instance; - private final BoardInfo boardInfo; + private BoardInfo boardInfo; static { instance = new BoardInfoHelper(); @@ -30,19 +30,23 @@ private BoardInfoHelper() { // Example output: c03111 var boardVersionCode = getBoardVersionCode(); - var boardModelByBoardCode = BoardModel.getByBoardCode(boardVersionCode); - if (boardModelByBoardCode != BoardModel.UNKNOWN) { - logger.info("Detected board type {} by code: {}", boardModelByBoardCode.name(), boardVersionCode); - this.boardInfo = new BoardInfo(boardModelByBoardCode, os, java); - return; + try { + var boardModelByBoardCode = BoardModel.getByBoardCode(boardVersionCode); + if (boardModelByBoardCode != BoardModel.UNKNOWN) { + logger.info("Detected board type {} by code: {}", boardModelByBoardCode.name(), boardVersionCode); + this.boardInfo = new BoardInfo(boardModelByBoardCode, os, java); + return; + } + } catch (Exception e) { + logger.warn("Could not detect the board type for code {}: {}", boardVersionCode, e.getMessage()); } // Example output: Raspberry Pi 4 Model B Rev 1.1 var boardName = getBoardName(); - boardModelByBoardCode = BoardModel.getByBoardName(boardName); - if (boardModelByBoardCode != BoardModel.UNKNOWN) { - logger.info("Detected board type {} by name: {}", boardModelByBoardCode.name(), boardName); - this.boardInfo = new BoardInfo(boardModelByBoardCode, os, java); + var boardModelByBoardName = BoardModel.getByBoardName(boardName); + if (boardModelByBoardName != BoardModel.UNKNOWN) { + logger.info("Detected board type {} by name: {}", boardModelByBoardName.name(), boardName); + this.boardInfo = new BoardInfo(boardModelByBoardName, os, java); return; } diff --git a/pi4j-core/test/java/com/pi4j/boardinfo/definition/BoardModelTest.java b/pi4j-core/test/java/com/pi4j/boardinfo/definition/BoardModelTest.java index bea8ddf4..995dd9d3 100644 --- a/pi4j-core/test/java/com/pi4j/boardinfo/definition/BoardModelTest.java +++ b/pi4j-core/test/java/com/pi4j/boardinfo/definition/BoardModelTest.java @@ -2,13 +2,12 @@ import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertAll; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; class BoardModelTest { @Test - void testGetBoardModelByBoardCode() { + void getBoardModelByBoardCode() { assertAll( () -> assertEquals(BoardModel.MODEL_5_B, BoardModel.getByBoardCode("d04170")), () -> assertEquals(BoardModel.MODEL_400, BoardModel.getByBoardCode("c03130")), @@ -21,17 +20,27 @@ void testGetBoardModelByBoardCode() { } @Test - void testGetBoardModelByBoardName() { + void getBoardModelByBoardName() { assertAll( () -> assertEquals(BoardModel.MODEL_4_B, BoardModel.getByBoardName("Raspberry Pi 4 Model B Rev 1.1")) ); } @Test - void testInstructionSetPico() { + void validateInstructionSetPico() { assertAll( () -> assertEquals(InstructionSet.ARM_V6_M, BoardModel.PICO.getSoc().getInstructionSet()), () -> assertEquals(InstructionSet.ARM_V6_M, BoardModel.PICO_2.getSoc().getInstructionSet()) ); } + + @Test + void boardCodesMustBeUnique() { + var codes = BoardModel.getAllBoardCodes(); + for (String code : codes) { + assertDoesNotThrow(() -> { + BoardModel.getByBoardCode(code); + }); + } + } }