Skip to content

Commit

Permalink
Merge pull request #80 from pulp-platform/aottaviano/fix-latch-ot
Browse files Browse the repository at this point in the history
treewide: Bump security island dependency
  • Loading branch information
alex96295 authored Jul 3, 2023
2 parents 35fa3a0 + 6a9adca commit 631c2d5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Bender.lock
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ packages:
- common_cells
- common_verification
opentitan:
revision: cce5a6e0bacba31374109969adcd7abb0f70f7ec
revision: 5ce64a6225e971c1e00ece29aa485f23a31aa7b2
version: null
source:
Git: https://github.com/alsaqr-platform/opentitan.git
Expand Down
2 changes: 1 addition & 1 deletion Bender.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies:
car_l2: { git: [email protected]:carfield/carfield_l2_mem.git, rev: 4239b2a510d65aa110bcc8a070e434cabd1a8b9a } # branch: main
safety_island: { git: [email protected]:carfield/safety-island.git, rev: 60e768a3ef29f47339e31674d497293f5a768893 } # branch: atops
pulp_cluster: { git: https://github.com/pulp-platform/pulp_cluster.git, rev: a746000f9dc9965e1351186905b59bca36edef57 } # branch: yt/carfield-integration
opentitan: { git: https://github.com/alsaqr-platform/opentitan.git, rev: cce5a6e0bacba31374109969adcd7abb0f70f7ec } # branch: yt/hartid
opentitan: { git: https://github.com/alsaqr-platform/opentitan.git, rev: 5ce64a6225e971c1e00ece29aa485f23a31aa7b2 } # branch: carfield
mailbox_unit: { git: [email protected]:pulp-platform/mailbox_unit.git, version: 1.1.0 }
apb: { git: https://github.com/pulp-platform/apb.git, version: 0.2.3 }
timer_unit: { git: https://github.com/pulp-platform/timer_unit.git, version: 1.0.2 }
Expand Down
19 changes: 6 additions & 13 deletions sw/tests/hostd/mbox_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,15 @@ int main(int argc, char const *argv[]) {
asm volatile("csrw mstatus, %0\n" : : "r"(global_irq_en )); // Set global interrupt enable in CVA6 csr
asm volatile("csrw mie, %0\n" : : "r"(external_irq_en)); // Set external interrupt enable in CVA6 csr
// PLIC setup
mmio_region_t plic_base_addr = mmio_region_from_addr(0x04000000);
mmio_region_t plic_base_addr = mmio_region_from_addr(0x03008000);
t = dif_rv_plic_init(plic_base_addr, &plic0);
t = dif_rv_plic_irq_set_priority(&plic0, mbox_id, prio);
t = dif_rv_plic_irq_set_enabled(&plic0, mbox_id, 0, kDifToggleEnabled);
writed(0xBAADC0DE, 0x40000008);
writed(0xBAADC0DE, 0x40000010);
writed(0xBAADC0DE, 0x40000014);
writed(0xBAADC0DE, 0x40000018);
writed(0xBAADC0DE, 0x4000001C);
a = readd(0x40000008);
b = readd(0x40000010);
c = readd(0x40000014);
d = readd(0x40000018);
e = readd(0x4000001C);
if( a == 0xBAADC0DE && b == 0xBAADC0DE && c == 0xBAADC0DE && d == 0xBAADC0DE && e == 0xBAADC0DE)
writed(0x00000001, 0x40000020); // ring doorbell if mailbox is accessible
writed(0xBAADC0DE, 0x40000B80);
a = readd(0x40000B80);
if( a == 0xBAADC0DE )
writed(0x00000001, 0x40000B04); // ring doorbell if mailbox is accessible
writed(0x00000001, 0x40000B0c);
wfi();
return 0;
}
21 changes: 11 additions & 10 deletions tb/carfield_fix.sv
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,11 @@ module carfield_soc_fixture;
};
//dm_ot::dtm_op_status_e op;
automatic int dmi_wait_cycles = 10;
$info(" JTAG Preloading start time");
$display("[JTAG SECD] JTAG Preloading Starting");
jtag_secd_dbg.wait_idle(300);
jtag_secd_dbg.get_idcode(idcode);
// Check Idcode
$display(" IDCode = %h", idcode);
$display("[JTAG SECD] IDCode = %h", idcode);
// Activate Debug Module
jtag_secd_dbg.write_dmi(dm_ot::DMControl, 32'h0000_0001);
do jtag_secd_dbg.read_dmi(dm_ot::SBCS, sbcs, dmi_wait_cycles);
Expand All @@ -405,22 +405,23 @@ module carfield_soc_fixture;
jtag_secd_dbg.write_dmi(dm_ot::SBCS, sbcs);
do jtag_secd_dbg.read_dmi(dm_ot::SBCS, sbcs, dmi_wait_cycles);
while (sbcs.sbbusy);
$display("======== Preload data to Secd SRAM ========");
// Start writing to SRAM
foreach (secd_sections[addr]) begin
$display("Writing %h with %0d words", addr << 2, secd_sections[addr]); // word = 8 bytes here
$display("[JTAG SECD] Writing %h with %0d words", addr << 2, secd_sections[addr]); // word = 8 bytes here
jtag_secd_dbg.write_dmi(dm_ot::SBAddress0, (addr << 2));
do jtag_secd_dbg.read_dmi(dm_ot::SBCS, sbcs, dmi_wait_cycles);
while (sbcs.sbbusy);
for (int i = 0; i < secd_sections[addr]; i++) begin
$display(" -- Word %0d/%0d", i, secd_sections[addr]);
if (i%100 == 0)
$display("[JTAG SECD] loading: %0d/100%%", i*100/secd_sections[addr]);
jtag_secd_dbg.write_dmi(dm_ot::SBData0, secd_memory[addr + i]);
// Wait until SBA is free to write next 32 bits
do jtag_secd_dbg.read_dmi(dm_ot::SBCS, sbcs, dmi_wait_cycles);
while (sbcs.sbbusy);
end
$display("[JTAG SECD] loading: 100/100%%");
end
$display("======== Preloading finished ========");
$display("[JTAG SECD] Preloading finished");
// Preloading finished. Can now start executing
sbcs.sbreadonaddr = 0;
sbcs.sbreadondata = 0;
Expand All @@ -440,7 +441,7 @@ module carfield_soc_fixture;
};
//dm_ot::dtm_op_status_e op;
automatic int dmi_wait_cycles = 10;
$info("======== Waking up Secd using JTAG ========");
$display("[JTAG SECD] Waking up Secd");
// Initialize the dm module again, otherwise it will not work
debug_secd_module_init();
do jtag_secd_dbg.read_dmi(dm_ot::SBCS, sbcs, dmi_wait_cycles);
Expand Down Expand Up @@ -473,7 +474,7 @@ module carfield_soc_fixture;
do jtag_secd_dbg.read_dmi(dm_ot::SBCS, sbcs, dmi_wait_cycles);

while (sbcs.sbbusy);
$info("======== Wait for Completion ========");
$display("[JTAG SECD] Wait for Completion");
endtask

task load_secd_binary;
Expand All @@ -483,12 +484,12 @@ module carfield_soc_fixture;

// Read ELF
void'(read_elf(binary));
$display("Reading %s", binary);
$display("[JTAG SECD] Reading %s", binary);

while (get_section(section_addr, section_len)) begin
// Read Sections
automatic int num_words = (section_len + AxiWideBeWidth_ib - 1)/AxiWideBeWidth_ib;
$display("Reading section %x with %0d words", section_addr, num_words);
$display("[JTAG SECD] Reading section %x with %0d words", section_addr, num_words);

secd_sections[section_addr >> AxiWideByteOffset_ib] = num_words;
buffer = new[num_words * AxiWideBeWidth_ib];
Expand Down
2 changes: 2 additions & 0 deletions tb/carfield_tb.sv
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ module tb_carfield_soc;
0: begin // JTAG
// Security Island
if (secd_preload_elf != "") begin
repeat(10000)
@(posedge fix.clk);
fix.debug_secd_module_init();
fix.load_secd_binary(secd_preload_elf);
fix.jtag_secd_data_preload();
Expand Down

0 comments on commit 631c2d5

Please sign in to comment.