編譯和仿真指令
基于版本:OAI_develop_210827。對nr-uesoftmodem,也就是 gUE進行解析。
下載下傳後編譯 先用git init指令,然後chmod 777 -R把檔案夾内權限設定一下。
develop的編譯:
sudo ./build_oai -w USRP --eNB --nrUE --gNB -g -G -V -x -P --ue-trace --ue-timing --build-lib telnetsrv --build-lib all
NR_UE_SA的編譯:
sudo ./build_oai -w USRP --eNB --nrUE --gNB -g -G -P --build-lib all
分别用-P和取消-P分别編譯一次。
gdb 仿真:
ue端:
sudo RFSIMULATOR=127.0.0.1 ./nr-uesoftmodem --rfsim --phy-test --rrc_config_path ./ -d
gNB端: (在ubuntu終端中輸入export RFSIMULATOR=server,并用env指令檢視)
sudo cgdb --args ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --rfsim --phy-test -d --command set enviroment RFSIMULATOR=server --rfsimulator.options saviq
usrp X310調試和仿真:
gNB端:
sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --phy-test -d
UE端調試:
sudo ./nr-uesoftmodem --numerology 1 -r 106 --ue-rxgain 40 --usrp-args addr=192.168.40.2 --phy-test --rrc_config_path ./ -d --clock-source 1
UE的參數配置說明見nr-uesoftmodem.h裡面的結構體:CMDLINE_NRUE_PHYPARAMS_DESC。重要的是兩個參數:-r 106(NRB)和收發均采用外部時鐘或者gps。
讀取配置
調試指令:
對NR_SSB的一些配置(讀取init_symbol_rotation()運作後的UE[CC_id]->frame_parms結構體):
{freq_range = nr_FR1, N_RB_DL = 106, N_RB_UL = 106, N_RBG = 0 '\000', N_RBGS = 0 '\000',
nr_band = 78, dl_CarrierFreq = 3619080000, ul_CarrierFreq = 3619080000, att_tx = 0,
att_rx = 0, frame_type = TDD, tdd_config = 3 '\003', Nid_cell = 0, subcarrier_spacing =
30000, threequarter_fs = 0 '\000', ofdm_symbol_size = 2048, nb_prefix_samples = 144,
nb_prefix_samples0 = 176, first_carrier_offset = 1412, symbols_per_slot = 14,
slots_per_subframe = 2, slots_per_frame = 20, samples_per_subframe = 61440,
get_samples_per_slot = 0x548de7 <get_samples_per_slot>, get_slot_from_timestamp = 0x0,
get_samples_slot_timestamp = 0x548ea6 <get_samples_slot_timestamp>, samples_per_slot0 =
30720,samples_per_slotN0 = 30688, samples_per_frame = 614400, samples_per_subframe_wCP =
57344, samples_per_slot_wCP = 28672, samples_per_frame_wCP = 573440, numerology_index = 1
'\001', nb_antennas_tx = 1 '\001', nb_antennas_rx = 1 '\001', nb_antenna_ports_gNB = 1
'\001', Ncp = NORMAL, symbol_rotation = {{18204, -27245, -23170, -23170, -27245, 18204,
12539, 30272, 32137, -6393, -1, -32767, -32138, -6393, -12540, 30272, 27244, 18204,
23169, -23170, -18205, -27245, -30273, 12539, 6392, 32137, 32767, 0, 18204,
-27245,-23170, -23170, -27245, 18204, 12539, 30272, 32137, -6393, 0, -32767, -32138,
-6393, -12540, 30272, 27244, 18204, 23169, -23170, -18205, -27245, -30273, 12539, 6392,
32137, 32766, 0 <repeats 393 times>}, {18204, -27245, -23170, -23170, -27245, 18204,
12539, 30272, 32137, -6393, -1, -32767, -32138, -6393, -12540, 30272, 27244, 18204,
23169, -23170, -18205, -27245, -30273, 12539, 6392, 32137, 32767, 0, 18204, -27245,
-23170, -23170, -27245, 18204, 12539, 30272, 32137, -6393, 0, -32767, -32138, -6393,
-12540, 30272, 27244, 18204, 23169, -23170, -18205, -27245, -30273, 12539, 6392, 32137,
32766, 0 <repeats 393 times>}}, nushift = 0 '\000', srs_nr = {active_srs_Resource_Set = 0
'\000', number_srs_Resource_Set = 0 '\000', p_SRS_ResourceSetList = {0x0}},
ss_PBCH_BlockPower = 0, p_tdd_UL_DL_Configuration = 0x0, p_tdd_UL_DL_ConfigurationCommon2
= 0x0, p_TDD_UL_DL_ConfigDedicated = 0x0, tdd_uplink_nr = {0 <repeats 320 times>},
half_frame_bit = 0 '\000', ssb_start_subcarrier = 396, ssb_type = nr_ssb_type_C, Lmax = 8
'\b', L_ssb = 9223372036854775808, N_ssb = 1 '\001', ssb_index = 0 '\000',
pbch_polar_params = {idx = 0, nextPtr = 0x0, n_max = 0 '\000', i_il = 0 '\000', i_seg = 0
'\000', n_pc = 0 '\000', n_pc_wm = 0 '\000', i_bil = 0 '\000', payloadBits = 0,
encoderLength = 0, crcParityBits = 0 '\000', crcCorrectionBits = 0 '\000', K = 0, N = 0,
n = 0 '\000', crcBit= 0, interleaving_pattern = 0x0, deinterleaving_pattern = 0x0,
rate_matching_pattern = 0x0, Q_0_Nminus1 = 0x0, Q_I_N = 0x0, Q_F_N = 0x0, Q_PC_N = 0x0,
information_bit_pattern = 0x0, channel_interleaver_pattern = 0x0, crc_generator_matrix =
0x0, G_N = 0x0, G_N_tab = 0x0, groupsize = 0, rm_tab = 0x0, cprime_tab0 = {{0 <repeats
256 times>} <repeats 32 times>}, cprime_tab1 = {{0 <repeats 256 times>} <repeats 32
times>}, B_tab0 = {{0 <repeats 256 times>} <repeats 32 times>}, B_tab1 = {{0 <repeats 256
times>} <repeats 32 times>}, extended_crc_generator_matrix = 0x0, nr_polar_crc = 0x0,
nr_polar_aPrime = 0x0, nr_polar_APrime = 0x0, nr_polar_D = 0x0, nr_polar_E = 0x0,
nr_polar_A = 0x0, nr_polar_CPrime = 0x0, nr_polar_B = 0x0, nr_polar_U = 0x0, tree = {root
= 0x0, num_nodes = 0}}}
# UE端資料接收:
由于每次發是按slot發送,接收也是按slot接收。要求收發時鐘對齊(兩個usrp同時接入gps),或者一個usrp參考另外一個usrp的時鐘。
代碼先進行同步,由nr_initial_sync()函數完成:
1. 第1步,該函數調用sync_pos= pss_synchro_nr()找到同步頭。 這個函數再調用pss_search_time_nr()找到幀頭位置(Peak found at pos XXX);
2. 第2步,再調用nr_gold_pbch(),随後rx_sss_nr()進行同步;
3. 第3步,檢查幀是否同步上(PSS同步頭是否檢測成功)。
nr_initial_sync(),到 ret = nr_pbch_detection(proc, ue, 1);語句,如果檢測成功傳回ret=0,否則為-1;
采用usrp的話, 在(ret==0)後打斷點,一直不能進入該條件。而仿真下則可以。
調用函數nr_rx_pbch()來傳回ret。在該函數中,包含nr_pbch_extract(),nr_pbch_channel_compensation(),nr_pbch_quantize()、和nr_pbch_unscrambling,最終由decoderState = polar_decoder_int16()。
4.
- 仿真
UE端口, 在phy_procedures_nrUE_RX()的起始位置處(這個還是隻有仿真時會運作到?),打斷點,并導出資料。
導出一個slot共2048*15000=30720000
dump binary memory ssb.bin &ue->common_vars->rxdata[0][0] &ue->common_vars->rxdata[0][0]+614400*4
或者在檢測到ssb後,pss_synchro_nr()的起始位置,打斷點,并導出資料。
dump memory ssb.bin &PHY_vars_UE->common_vars->rxdata[0][0] &PHY_vars_UE->common_vars->rxdata[0][0]+614400*4
# 讀取接收儲存的檔案
讀取為gdb通過 指令 dump binary memory導出的檔案。
matlab讀取的對應代碼為:
clear;clc;close all;
fid = fopen('Z:\work\data\ssb.bin','r');
txdata_IQ = fread(fid,inf,'int16');
fclose(fid);
txdata_I = txdata_IQ(1:2:end-1);
txdata_Q = txdata_IQ(2:2:end);
txdata_comp = txdata_I + 1j * txdata_Q;
plot(txdata_I);
圖形如下:
# matlab仿真
采用5G toolbox裡面的NRSynchronizationProceduresExample()進行仿真SSB,配置如下:```
burst.BlockPattern = 'Case C'; %by getSSBSubcarrierSpacing(), getting the
burst.SSBPeriodicity = 20;
burst.NFrame = 4;
burst.SSBTransmitted = [1 0 0 0];
burst.NCellID = 102;
% Burst configuration related to carrier (10 MHz, see TS 38.104 Table
% 5.3.2-1):
gnb.SubcarrierSpacing = 30; %%subcarrier_spacing = 30000
gnb.NRB = 106; %%N_RB_DL=106 gnb.NRB = 52
gnb.CyclicPrefix = 'Normal';
carrierInfo = hOFDMInfo(gnb);
burst.SampleRate = carrierInfo.SamplingRate;
K = carrierInfo.NSubcarriers;
burst.FrequencyPointA = -K/2 * gnb.SubcarrierSpacing * 1e3;
% Burst configuration related to MIB content:
burst.DMRSTypeAPosition = 2;
burst.PDCCHConfigSIB1 = 17;
burst.CellBarred = 0;
burst.IntraFreqReselection = 0;
burst.SubcarrierSpacingCommon = carrierInfo.SubcarrierSpacing;
burst.DisplayBurst = true;